home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / rap101.zip / RAP.MAN < prev    next >
Text File  |  1992-05-08  |  222KB  |  6,131 lines

  1.  
  2.                                 
  3.                                 
  4.                                 
  5.                                 
  6.                                 
  7.                                THE
  8.  
  9.                                RAP
  10.  
  11.                       PROGRAMMING LANGUAGE
  12.                                 
  13.                                 
  14.                                 
  15.                                 
  16.                                 
  17.                                 
  18.  
  19.  
  20.                                 
  21.                       Richard A. Strangfeld
  22.                                 
  23.  
  24.  
  25.                                 
  26.  
  27.  
  28.                                 
  29.  
  30. Occasional Publications in Academic Computing
  31.  
  32. Number 10
  33.  
  34.                                 
  35.  
  36.  
  37.                                 
  38.  
  39.  
  40.                                 
  41.                                 
  42.                                 
  43.                                 
  44.                                 
  45.                                 
  46.                                 
  47.                                 
  48.                                 
  49.                                 
  50.                                 
  51.                  Summer Institute of Linguistics
  52.                           Dallas, Texas
  53.  
  54.  
  55. This book is sold with the software it describes.  That software,
  56. too, is  the copyrighted  property of  the  Summer  Institute  of
  57. Linguistics.   However, in  the interest  of sharing the fruit of
  58. our research  with the  larger academic community, the registered
  59. owner of the RAP software is granted the right to share copies of
  60. the distribution  diskette with  friends and associates, provided
  61. this is  not done  for commercial  gain.   Such recipients of the
  62. software, if  they decide  to use it in their research, should in
  63. turn become registered owners by buying this book with its latest
  64. version of the software.
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.                                   
  81.                                 
  82.                                 
  83.       Copyright 1988 by the Summer Institute of Linguistics
  84.                        All rights reserved
  85.  
  86.                             CONTENTS
  87.  
  88.  
  89.  
  90.  
  91.              Part I:  A Tutorial Introduction to RAP
  92.  
  93.  
  94. 1. Introduction                                  3
  95.  
  96. 1.1 What you need to run RAP                     4
  97.  
  98. 1.2 Some history                                 5
  99.  
  100. 1.3 The current version                          5
  101.  
  102. 1.4 The READ.ME file                             6
  103.  
  104. 1.5 About this book                              6
  105.  
  106.  
  107. 2. Getting started                               7
  108.  
  109. 2.1 A one-line program:  the t command           8
  110.  
  111. 2.2 Introducing variables:  the a command        9
  112.  
  113. 2.3 Assigning values to variables               10
  114.  
  115. 2.4 More on the screen:  cls, foot, and th      12
  116.  
  117.  
  118. 3. Flow of control                              15
  119.  
  120. 3.1 Conditionals:  the if construct             16
  121.  
  122. 3.2 Repeated execution:  the loop construct     19
  123.  
  124. 3.3 Making choices:  the menu construct         21
  125.  
  126.  
  127. 4. Subprograms                                  25
  128.  
  129. 4.1 Procedures:  an introduction                26
  130.  
  131. 4.2 Procedures with arguments                   29
  132.  
  133. 4.3 Returning a value:  functions               31
  134.  
  135. 4.4 An aside:  comments                         34
  136.  
  137. 4.5 Local and global variables                  35
  138.  
  139. 4.6 Organizing a RAP program                    36
  140.  
  141.  
  142. 5. String operations                            37
  143.  
  144. 5.1 String evaluation                           38
  145.  
  146. 5.2 String comparison                           43
  147.  
  148. 5.3 Pattern matching: has and contains          44
  149.  
  150. 5.4 Advanced matching:  regular expressions     46
  151.  
  152.  
  153. 6. Numeric operations                           51
  154.  
  155. 6.1 Arithmetic operations                       52
  156.  
  157. 6.2 Comparing numbers                           52
  158.  
  159. 6.3 Logical operations (and parentheses)        53
  160.  
  161. 6.4 Converting between strings and numbers      54
  162.  
  163.  
  164. 7. Advanced dialogue features                   55
  165.  
  166. 7.1 Special effects on the screen: using ANSI.SYS 56
  167.  
  168. 7.2 Advanced input:  as, ah, and *keypress      57
  169.  
  170. 7.3 Customized menus                            59
  171.  
  172.  
  173. 8. File operations                              63
  174.  
  175. 8.1 Working with data files                     64
  176.  
  177. 8.2 Getting information about files             69
  178.  
  179. 8.3 Getting information about disks             71
  180.  
  181. 8.4 Advanced file operations                    73
  182.  
  183.  
  184. 9. Calling other programs                       77
  185.  
  186. 9.1 Using DOS commands from within RAP          78
  187.  
  188. 9.2 Calling non-RAP programs from RAP           80
  189.  
  190. 9.3 Chaining to another RAP program             81
  191.  
  192. 9.4 Chaining with a batch file                  83
  193.  
  194. 9.5 Getting information about the system        83
  195.  
  196.  
  197. 10. The programming environment                 85
  198.  
  199. 10.1 Load, run, and related commands            86
  200.  
  201. 10.2 Setting up your disks                      88
  202.  
  203. 10.3 Debugging a RAP program:  debug and trace  89
  204.  
  205. 10.4 The xi command                             93
  206.  
  207. 10.5 The .include command                       94
  208.  
  209.  
  210. 11. Notes on programming style                  97
  211.  
  212. 11.1 Writing better RAP programs                98
  213.  
  214. 11.2 Writing faster RAP programs               102
  215.  
  216.                                 
  217.  
  218.                Part II:  A Reference Guide to RAP
  219.  
  220.  
  221. 12. Elements of the language                   109
  222.  
  223. 12.1 Lexical conventions                       110
  224.  
  225. 12.2 Names                                     110
  226.  
  227. 12.3 Variables                                 111
  228.  
  229. 12.4 Built-in variables                        112
  230.  
  231. 12.5 Arrays                                    115
  232.  
  233. 12.6 Numeric expressions                       116
  234.  
  235. 12.7 Strings and string expressions            117
  236.  
  237. 12.8 Pattern matching                          119
  238.  
  239. 12.9 Statements                                120
  240.  
  241. 12.10 Flow of control                          121
  242.  
  243. 12.11 Programs                                 124
  244.  
  245.  
  246. 13. The interpreter                            125
  247.  
  248. 13.1 Loading and running                       126
  249.  
  250. 13.2 File access                               129
  251.  
  252. 13.3 Command-line arguments                    131
  253.  
  254. 13.4 Limits                                    132
  255.  
  256. 13.5 Normal, small, and large RAP              133
  257.  
  258. 13.6 Memory usage                              134
  259.  
  260.  
  261. 14. Command descriptions                       135
  262.  
  263.  
  264. 15. Built-in function descriptions             179
  265.  
  266.  
  267. 16. Error and warning messages                 197
  268.  
  269.  
  270. References                                     217
  271.  
  272.  
  273. Glossary                                       219
  274.  
  275.  
  276. Appendixes                                     227
  277.  
  278. A. Summary of commands, functions, and variables 228
  279.  
  280. B. Formal syntax definition                    231
  281.  
  282. C. ANSI screen-control codes                   238
  283.  
  284. D. Input codes for special keys                240
  285.  
  286. E. Differences between RAP models              242
  287.  
  288.  
  289. Index                                          244
  290.  
  291. __________________________________________________
  292.  
  293. Chapter 1
  294.  
  295.  
  296. INTRODUCTION
  297.  
  298.  
  299.       1.1  What you need to run RAP
  300.  
  301.       1.2  Some history
  302.  
  303.       1.3  The current version
  304.  
  305.       1.4  The READ.ME file
  306.  
  307.       1.5  About this book
  308.  
  309.  
  310.   RAP  is   a  programming   language  intended  to  help  put  a
  311. "friendlier" layer  between "unfriendly" complicated programs and
  312. their users.   An  experienced user of some complex program could
  313. write  a  RAP  program  to  help  his  or  her  less  experienced
  314. colleagues.  That RAP program might ask questions and offer menus
  315. to the  user in  a "friendly" fashion, then pass the instructions
  316. obtained to  the other program in whatever "unfriendly" format it
  317. required.
  318.  
  319.   A typical  use of  RAP might  be with IT--the interlinear  text
  320. processing system (Simons and Versaw 1988).  This system consists
  321. of a  number of  programs for  manipulating interlinear annotated
  322. text.   Most of these programs get their instructions on what the
  323. user wants to do from a "control file."
  324.  
  325.   Without RAP,  the user  must use  a text  editor  to  type  the
  326. control file  by hand.   This  file is written to rather exacting
  327. specifications; the  user generally works with a book open to the
  328. page giving  those specifications  in order to see what is needed
  329. and in  what format.  After creating and saving the control file,
  330. the  user   might  type   something  like    itprep  -f  prep.ctl
  331. chumash.txt to run an IT program.
  332.  
  333.   With RAP,  you can  set up  a "friendly"  program to handle the
  334. messy details  that the  IT programs require.  When run, this RAP
  335. program would  present the  user with  a set  of  multiple-choice
  336. menus and  other questions.   It  would provide  explanations and
  337. extra helps  as needed.   It would ask all the questions required
  338. for the operation selected, automatically write the control file,
  339. and automatically run the proper IT program.
  340.  
  341. 1.1 What you need to run RAP
  342.  
  343.   RAP runs  on any of the following computers, provided it has at
  344. least 128K of memory[1] and is using DOS 2.0 or later:
  345.  
  346.        1. an IBM PC or compatible  
  347.        2. a Sharp PC-5000     
  348.        3. any MS-DOS computer that responds to IBM or ANSI  
  349.           screen commands.
  350.  
  351.   The easiest  way to  start learning  RAP is to make a disk that
  352. contains RAP.EXE, COMMAND.COM, and your favorite text editor, and
  353. then do  everything on  that one  disk.   This  arrangement  will
  354. suffice for  working through  the examples  in this book.  If you
  355. find yourself  running out  of room  on that  disk, read  section
  356. 10.2.
  357.  
  358. 1.2 Some history
  359.  
  360.   RAP is  derived from  the PILOT  programming  language  (Stark-
  361. weather 1969).   PILOT  is a  computer-aided instruction language
  362. intended for use by novice programmers.  RAP (whose name was once
  363. Rational Pilot)  has many  of the  features of  PILOT,  but  adds
  364. enhancements that  make the  language more  structured  and  more
  365. powerful.   There are  three key  additions:   structured program
  366. control constructs  (with the  removal of  jumps), parameters for
  367. called subprograms,  and local  variables.  These changes make it
  368. easier to write clear and useful programs in RAP.  Apart from the
  369. enhancements, most RAP commands come from ordinary PILOT.
  370.  
  371. 1.3 The current version
  372.  
  373.   This book  accompanies version  1.0 of RAP. We ask for feedback
  374. in terms  of suggested  improvements, bug reports, and especially
  375. ways that  you  have  been  able  to  use  RAP.    We  intend  to
  376. incorporate good sample programs developed in the field in future
  377. formal  releases  of  RAP.    Comments,  corrections,  questions,
  378. suggestions, and  especially  sample  programs  are  welcome  and
  379. encouraged. Please direct these to:
  380.  
  381.     Academic Computing -- RAP Development
  382.     Summer Institute of Linguistics
  383.     7500 W. Camp Wisdom Road
  384.     Dallas, Texas 75236
  385.  
  386.   Before you contact us, please check the exact version number of
  387. RAP that  you are using and include that in your report.  You can
  388. find this out by starting RAP without giving it a program to run.
  389. If you  are reporting  a bug, it can be very helpful to send us a
  390. disk containing  the RAP  program you  wrote  that  revealed  the
  391. problem, and even a copy of the RAP.EXE program file that you are
  392. using.
  393.  
  394.   The RAP  distribution disk  includes the  normal version of RAP
  395. (RAP.EXE) and  two variants.  The normal version will suffice for
  396. learning RAP and for most ongoing use.  The variants are SmallRAP
  397. (SMALLRAP.EXE) which has fewer features but uses less memory, and
  398. LargeRAP (LARGERAP.EXE)  which allows  very large  RAP  programs.
  399. The differences  between them  and normal  RAP are  discussed  in
  400. section 13.5 and appendix E.
  401.  
  402.   Also included  on the  RAP  distribution  disk  is  the  COMMON
  403. subroutine library  developed by  Kirk Parker  and  Gary  Simons.
  404. This is a collection of predefined procedures and functions which
  405. make it  easier to  write reliable  interactive programs.   It is
  406. fully documented in a companion volume (Parker and Simons 1988).
  407.  
  408. 1.4 The READ.ME file
  409.  
  410.   You may  find a  file called READ.ME on your RAP diskette along
  411. with RAP.EXE  and related  program files.   READ.ME  contains any
  412. additions or corrections to this book that relate to your version
  413. of RAP,  and  explains  any  sample  programs  or  tools  on  the
  414. diskette.   It would  be wise  to read or print it before reading
  415. this book in detail.
  416.  
  417. 1.5 About this book
  418.  
  419.   This book contains a tutorial section, a reference section, and
  420. several appendixes.   The  tutorial, chapters  2 through 11, uses
  421. examples to  explain the  more frequently-used  RAP commands.  It
  422. leads from  simple statements  to  more  complex  statements  and
  423. groups of statements.  The reference section, chapters 12 through
  424. 16, provides  a more concise and orderly description of RAP.  The
  425. appendixes summarize the commands and syntax of the language, and
  426. provide other reference material.
  427.  
  428.   As with any language, it is easier to learn RAP if you have had
  429. some  experience   with  other  languages--in  this  case,  other
  430. programming languages.   If you haven't, don't fear.  People have
  431. learned to  write useful  RAP programs  using this  book with  no
  432. prior experience.   We have tried to gear the tutorial section to
  433. the novice  while aiming  the reference  section at  the somewhat
  434. more experienced  programmer.   This  does  mean  that  the  book
  435. contains  something   inappropriate  for   everyone.     Bear  it
  436. patiently.
  437.  
  438.  
  439. ____________________
  440.  
  441.   1 If  your computer  only has 128K, you will not be able to run
  442. some RAP  programs that  call other programs.  You'll have better
  443. results with SmallRAP (see section 13.5), though there will still
  444. be limitations.
  445.  
  446.  
  447. ----------------------------------------------------------------
  448.  
  449. Chapter 12
  450.  
  451.  
  452. ELEMENTS OF THE LANGUAGE
  453.  
  454.  
  455.       12.1  Lexical conventions
  456.  
  457.       12.2  Names
  458.  
  459.       12.3  Variables
  460.  
  461.       12.4  Built-in variables
  462.  
  463.       12.5  Arrays
  464.  
  465.       12.6  Numeric expressions
  466.  
  467.       12.7  Strings and string expressions
  468.  
  469.       12.8  Pattern matching
  470.  
  471.       12.9  Statements
  472.  
  473.       12.10  Flow of control
  474.  
  475.       12.11  Programs
  476.  
  477.  
  478.   This chapter  describes the elements of RAP from the bottom up,
  479. working from character-level concerns up to programs.
  480.  
  481. 12.1 Lexical conventions
  482.  
  483.   RAP allows one statement per line.  A statement may occupy more
  484. than one  line if  each line  but the  last has  a plus  sign (+)
  485. appended as  its last  character.  A statement, including all its
  486. continuations, may  be up  to 255 characters long.  When any line
  487. ends with  a nonescaped  plus sign,  the next line is appended to
  488. it.
  489.  
  490.   The use  of white  space (blanks,  blank lines,  and tabs) in a
  491. program is  encouraged for readability.  The loader ignores blank
  492. lines, leading blanks on any line (including continuation lines),
  493. and blank  space between  keywords.  Trailing blanks are ignored.
  494. White space is not allowed within a name or keyword, or before an
  495. array subscript.
  496.  
  497.   Comments are  also encouraged  for readability.   There are two
  498. kinds:  remarks and in-line comments.  The loader strips out both
  499. kinds when it reads the program.
  500.  
  501.   A remark is a statement beginning with the r keyword; the whole
  502. statement is  ignored.  An in-line comment can come at the end of
  503. any statement or on a blank line.  It begins with white space and
  504. a semicolon (or a semicolon at the beginning of a line), and runs
  505. to the end of the line.  When a statement is continued on several
  506. lines, only the last line may have a comment.
  507.  
  508. 12.2 Names
  509.  
  510.   String variable  names start  with a dollar sign, followed by a
  511. letter and  up to nineteen[1] additional  characters  (which  are
  512. alphanumerics or  underscores).   All characters  in a  name  are
  513. significant.   Case is  ignored.  Spaces are not allowed within a
  514. name, or between an array name and its subscript.
  515.  
  516.   Numeric variable  names are  similar,  except  that  the  first
  517. character is a pound sign (#) instead of a dollar sign.  There is
  518. no conflict  if the  names of a string variable and a numeric one
  519. have the same alphanumeric part, as in #line versus $line.
  520.  
  521.   An array  name (see  section 12.5)  is just  like  an  ordinary
  522. string or  numeric variable  name, but it is immediately followed
  523. by a numeric subscript expression in square brackets.
  524.  
  525.   Names of  functions are  similar to  variable names,  but begin
  526. with an  asterisk (*).   Names  of  procedures  have  no  special
  527. character at  the beginning;  they  just  start  with  a  letter.
  528. Subprogram names  do not  conflict with  similar variable  names:
  529. *line,  #line,   and  $line   can  all   coexist  peacefully  (if
  530. confusingly).   However, functions  and procedures  with  similar
  531. names will  conflict:   *line and line can't both be used.  Also,
  532. RAP command names should not be used as procedure names.
  533.  
  534.   Symbolic constants  (defined  with  the  .define  command)  are
  535. similar, but  begin with  a period.   As with variables, the full
  536. name is  significant, case  is ignored,  and blanks within a name
  537. are not  permitted.   You should  avoid using  .include, .define,
  538. .undef, and  .undefine as  names of  constants, since  they  have
  539. special meaning  to the loader.  The names .ifdef, .else, .endif,
  540. and .pragma are reserved for future use.
  541.  
  542. 12.3 Variables
  543.  
  544.   RAP has  two data  types:   string and  numeric.   Variables of
  545. either type can be global, local, or built-in.
  546.  
  547.   A string  variable holds a stream of characters.  It is limited
  548. to a maximum length of 255 characters, and may not contain nulls.
  549. Normal printing  characters and  the upper  half of the character
  550. set (through  ASCII 255)  may be used freely.  Control characters
  551. (ASCII 31 and below) should only be used with caution.  A numeric
  552. variable  holds   a  long   integer,  between   -2147483640   and
  553. 2147483640.   Numbers are  expressed in base ten when output, and
  554. are assumed  to be  in that  form when input or when appearing in
  555. expressions.  RAP does not provide built-in conversion to or from
  556. octal or hexadecimal.
  557.  
  558.   Variables in  RAP are  local,  global,  or  built-in.    Global
  559. variables are  known in  the main  procedure and everywhere else.
  560. Local variables  are declared  in some  subprogram (procedure  or
  561. function), and  are known  only in  that subprogram  and  in  any
  562. subprograms that  it calls.   Programmers should take note:  this
  563. is not  quite conventional.   The scope of a variable is dynamic,
  564. is determined  at run  time, and depends entirely on the order in
  565. which subprograms call one another.  The built-in variables are a
  566. predefined set listed in the next section.
  567.  
  568.   The same  variable can be declared on several levels.  That is,
  569. when a  main procedure  calls a  subprogram which  calls  another
  570. program, variables  with the same name may be locally declared in
  571. each of them.  When such a variable is referenced, the most local
  572. (lowest level)  copy is  the one used.  Higher-level instances of
  573. that variable  are preserved  and inaccessible  until the  lower-
  574. level subprograms terminate.
  575.  
  576.   Declaration is  not required.   If  an assignment is made to an
  577. undeclared  variable,  that  variable  is  created  as  a  global
  578. variable.   Declaration assigns a value of 0 to numeric variables
  579. and "" (nothing) to string ones.
  580.  
  581. 12.4 Built-in variables
  582.  
  583.   RAP provides  a number  of special-purpose  built-in variables,
  584. given in  alphabetical order  and described  below.   They may be
  585. assigned new  values, though  as noted  below this  is  sometimes
  586. unwise.   Local  copies  of  these  variables  will  be  used  if
  587. declared.
  588.  
  589. $blank
  590.  
  591.   This variable  contains a  single space.   Sometimes  the  name
  592. $blank is  easier to see in text than a literal space.  It can be
  593. used to  provide trailing  blanks which the loader will not strip
  594. off in  an assignment  or th  statement.   Assigning a  different
  595. value to this variable is legal, but is apt to lead to confusion.
  596.  
  597. #case
  598.  
  599.   This determines  whether or  not case  is significant in string
  600. comparison and  pattern matching  operations.   If #case is zero,
  601. case is  ignored.   If #case is nonzero, case is considered.  The
  602. default is 1.
  603.  
  604. $cmdline
  605.  
  606.   This variable  contains any  command-line  arguments  given  on
  607. entering RAP,  except for  the program name and arguments used by
  608. the RAP  interpreter.   Arguments are  separated by  blanks,  and
  609. appear in  the order in which they were typed.  See section 13.3.
  610. This variable  may be  assigned a  value.  The global instance of
  611. $cmdline is  also used  in passing  information  to  another  RAP
  612. program called with run.
  613.  
  614. $left
  615.  
  616.   When a  pattern matching  operation using  contains succeeds in
  617. matching a  pattern to some portion of a string, this variable is
  618. assigned the  portion of  the string  to the  left of the matched
  619. section.   If the  match operation  fails, this  variable is  not
  620. touched.   If there  has not yet been a match operation, $left is
  621. not defined.   It is often a good idea to declare a local copy of
  622. $left when using contains in a subprogram, to avoid affecting any
  623. $left used in the main program.
  624.  
  625. $match
  626.  
  627.   When a  pattern matching  operation using  contains succeeds in
  628. matching a  pattern to some portion of a string, this variable is
  629. assigned the  portion of  the  string  matched.    If  the  match
  630. operation fails,  this variable is not touched.  If there has not
  631. yet been  a match  operation, $match is not defined.  Declaring a
  632. local copy of $match is generally a good idea if you use contains
  633. in a subprogram.
  634.  
  635. $newline
  636.  
  637.   This variable  contains the newline character (line feed, which
  638. also triggers a return[2] when displayed).   It  is often  useful
  639. embedded in  text  that  is  to  be  displayed  or  passed  to  a
  640. subprogram.   As with  $space, this  variable can  be assigned  a
  641. different value but at the risk of confusion.
  642.  
  643. #paged
  644.  
  645.   This variable  controls the  automatic  pausing  that  normally
  646. occurs after each full screen[3] of output. If #paged is nonzero,
  647. pausing will  occur.   The default is 1.  Assigning this variable
  648. (or a local copy) a zero value will suppress the pausing.
  649.  
  650. $path
  651.  
  652.   This is  the directory path list used by RAP in accessing files
  653. (for edit, *existf, *findpath, .include, load, *open, run, xcall,
  654. and xchain)  when the  file specified is not found in the current
  655. directory.   It is  initially given  the value  of the  DOS  path
  656. environment variable, but it can be assigned a different value or
  657. a local  copy can  be used.   Nothing  that is  done to this will
  658. affect the path environment variable in DOS.
  659.  
  660.   To get  a single  backslash in a path, you must assign a double
  661. backslash to  $path; thus  $path=C:\\RAP;C:\\BIN;  will  give  an
  662. effective path  of C:\RAP;C:\BIN;  .   (When RAP reads in the DOS
  663. path on startup, it handles this detail automatically.)  For best
  664. results, put the path in all caps, and follow the last entry with
  665. a semicolon.
  666.  
  667. $prompt
  668.  
  669.   This is  the prompt  displayed when RAP asks for input from the
  670. user in  an a  or ah  statement.   It defaults  to ?  but can  be
  671. assigned a  new value.  If a local copy of $prompt is declared in
  672. a subprogram, it will be used.
  673.  
  674. #result
  675.  
  676.   This shows  the error  code returned  by the  most recent xcall
  677. command.   If xcall  runs a program which returns a code, #result
  678. is set  to that  code.   If xcall  is unable  to run the program,
  679. #result is -1.  Otherwise, #result is set to 0.
  680.  
  681. $right
  682.  
  683.   When a  pattern matching  operation using  contains succeeds in
  684. matching a  pattern to some portion of a string, this variable is
  685. assigned the  portion of  the string  to the right of the matched
  686. section.   If the  match operation  fails, this  variable is  not
  687. touched.   If there has not yet been a match operation, $right is
  688. not defined.   Declaring  a local  copy of  $right is generally a
  689. good idea if you use contains in a subprogram.
  690.  
  691. $screentype
  692.  
  693.   This variable  shows what  kind of  computer is  in use.    The
  694. current possibilities  are Sharp LCD, ANSI, and IBM.  On startup,
  695. RAP does  some tests  to determine  the kind  of computer,[4] and
  696. assigns this  variable a  value accordingly.   You  can assign  a
  697. different  value,   but  this   will  not   affect  RAP's  screen
  698. operations.
  699.  
  700.   The Sharp LCD  screentype is used for the Sharp PC-5000 with an
  701. 8-line LCD screen.  ANSI is any other system that responds to the
  702. ANSI control  codes (see section 7.1), such as an IBM PC with the
  703. ANSI.SYS driver  installed.   If the computer is  not a Sharp PC-
  704. 5000 and  does not  respond to  ANSI codes,  RAP assumes that you
  705. have an IBM PC or close compatible, and uses the IBM screentype.[5]
  706.  
  707. #sstep
  708.  
  709.   This controls single-step tracing when LargeRAP is run with the
  710. /trace option.   If  #sstep is nonzero, RAP displays and runs one
  711. step at  a time.   If it is zero, RAP runs normally.  See section
  712. 10.3 for more details.
  713.  
  714. $tag
  715.  
  716.   When RAP is displaying a menu, this variable holds the response
  717. tag (e.g.,  a, b,  etc.) of  the most  recently processed option.
  718. This can  be embedded  in the text of an option, or in the prompt
  719. text that is shown after the last option.
  720.  
  721. $version
  722.  
  723.   Identifies the  version of  RAP that is running, including both
  724. the version number and the possible annotation Small or Large.
  725.  
  726. 12.5 Arrays
  727.  
  728.   RAP supports arrays, though in a somewhat limited fashion.  Any
  729. variable name  may be  immediately followed by a subscript, which
  730. is a  numeric expression  in square  brackets.  The value of that
  731. expression may be anything between 0 and 999.  Only one subscript
  732. is allowed;  arrays are  one-dimensional.  A subscripted variable
  733. name may  appear anywhere a normal scalar (ordinary) variable may
  734. appear, except in a parameter in a proc or function statement.
  735.  
  736.   An explanation  of how  arrays are currently implemented in RAP
  737. should shed  light on  their current limitations.  When RAP comes
  738. across a  variable name  immediately followed  by a  square  left
  739. bracket, it  evaluates the  subscript.  It attaches a three-digit
  740. decimal number  representing that  subscript to the variable name
  741. in place  of the  bracketed subscript, and from then on treats it
  742. as the name of a scalar variable.
  743.  
  744.   Thus if #i is 7 and #j is 2, the statement:
  745.  
  746.     $line[#i] =$oldline[#j+1]
  747.  
  748. is converted on execution to (and treated internally as):
  749.  
  750.     $line007 =$oldline003
  751.  
  752.   Most of the time this behavior is fine; it really does give you
  753. working arrays.   One  drawback is  the potential for conflict if
  754. you already  have variables  with similar names.  Another is that
  755. array names  are limited to 17 instead of 20 characters.  A third
  756. is that  you can't  pass a  whole array  as an  argument to (or a
  757. returned value from) a subprogram.
  758.  
  759.   The only  exception  to  the  above  description  is  in  RAP's
  760. handling of subscripts in a declare statement.  There, RAP treats
  761. the subscript  as a  maximum size and creates local variables for
  762. each possible member. The statement
  763.  
  764.     declare $line[4]
  765.  
  766. is treated as
  767.  
  768.     declare $line000,$line001,$line002,$line003,$line004
  769.  
  770.   As  with   scalar  (nonarray)  variables,  declaration  is  not
  771. required.   Declaring an  array in  a subprogram ensures that all
  772. its members  will go  away on returning from that subprogram.  In
  773. contrast, any  member assigned  a value in an undeclared array is
  774. created as  a global  variable, and  these  will  all  remain  on
  775. returning.   The problem  is no  different with scalars (ordinary
  776. variables), but with array members there are likely to be more of
  777. them.
  778.  
  779.   This description  of the  internal implementation  of arrays is
  780. provided to  clarify their  current limitations.    It  would  be
  781. unwise to  write code that depends on the equivalence of $line[7]
  782. and $line007, since implementation details can change.
  783.  
  784. 12.6 Numeric expressions
  785.  
  786.   As there  are two  kinds of  data in RAP, there are two sets of
  787. operations:    those  involving  numeric  expressions  and  those
  788. involving strings.
  789.  
  790.   The syntax for numeric expressions in RAP is very conventional,
  791. and is  described in  detail in  appendix B.   The  precedence of
  792. operators is as follows:
  793.  
  794.     1.  ( ), not, unary minus,[6] unary plus   (highest)
  795.     2.  *,  /,  mod, rem
  796.     3.  +, -
  797.     4.  <,<=,==,<>,>,>=
  798.     5.  and
  799.     6.  or                                     (lowest)
  800.  
  801.   The operators  in groups  2 and  3 group  left-to-right.    The
  802. division operator  (/) does integer division, mod is modulus, and
  803. rem is  remainder.  Modulus and remainder are identical when they
  804. have  positive   operands  but  differ  with  negative  ones,  as
  805. illustrated in the following chart:
  806.   
  807.          #a     #b    #a/#b   #a mod #b   #a rem #b
  808.          11      5       2         1          1
  809.         -11      5      -2         4         -1
  810.          11     -5      -2        -4          1
  811.         -11     -5       2        -1         -1
  812.  
  813.  
  814.   There are  no bitwise  operators.   The logical  and comparison
  815. operators (not,  and, or,  and all  of group 4) treat zero-valued
  816. arguments as logically false and anything else as logically true.
  817. They return  zero for  false and  one for  true.   Unlike  the  C
  818. language, RAP evaluates both operands in a logical operation even
  819. when the value of the first one makes the second one moot.
  820.  
  821.   Conversion of  string to numeric data is done with the built-in
  822. *value function;  the *isnumber  and *isnumexp functions test for
  823. the  possibility  of  this  conversion.    Conversion  of  single
  824. characters to  their ASCII  numeric equivalents  is done with the
  825. *ascii function.
  826.  
  827.   The same  comparison operators  apply to string comparison, and
  828. similarly result  in a  1 or  0 outcome.  In a string comparison,
  829. the two arguments are string expressions as described below.  The
  830. arguments are evaluated and then compared character-by-character.
  831. As soon  as a  difference is  found, the  string with  the lesser
  832. character (per the ASCII sequence, with case possibly ignored) is
  833. treated as  the lesser  string.   If one  string ends  before the
  834. other but  they match until that point, the shorter string is the
  835. lesser.   If they  are the  same length and match fully, they are
  836. equal.
  837.  
  838.   The distinction  between  upper  and  lower  case  is  normally
  839. ignored in  string comparisons.   This can be changed by altering
  840. the value  of the built-in variable #case, or a local variable of
  841. the same name.  If #case is 0, case is ignored.  If it is 1, case
  842. is taken into account.  The default is 0.
  843.  
  844.   Two  additional   string  comparison  operators  allow  pattern
  845. matching; these  are has  and contains.   They  are described  in
  846. section 12.8.
  847.  
  848. 12.7 Strings and string expressions
  849.  
  850.   A string  is a  stream of  text, up  to 255 characters long.  A
  851. string does  not normally  appear in quotes.  A string expression
  852. is used  in string  comparisons, in arguments to subprograms, and
  853. in the  return statement for a string function.  It may be either
  854. a string in quotes, a string variable, or a string function call.
  855. You can  include quotes in a quoted string by preceding them with
  856. a backslash.
  857.  
  858.   RAP evaluates  a string  expression before using it.  There are
  859. two kinds  of string  evaluation:   normal  and  final.    Normal
  860. evaluation consists  of scanning  the string  once from  left  to
  861. right, finding  any variable  names or function calls embedded in
  862. the string,  and replacing  them with their values.  This happens
  863. whenever a string is used; more specifically, when it:
  864.  
  865.     1. is on the right side of an assignment, or
  866.     2. is an argument to virtually any command, or
  867.     3. is an argument in a call to a subprogram.
  868.  
  869.   Final evaluation  takes care  of escaping backslashes and final
  870. ones.   It occurs  after normal evaluation when a string is going
  871. from RAP  to the  outside world,  and in  a few other situations.
  872. More exactly, final evaluation occurs when a string:
  873.  
  874.     1. is output to a file or the screen (as in t and th,
  875.        foot, option, and prompts), or
  876.     2. is passed to DOS (as in dir, killf, load, run, xcall,
  877.        xchain, xs, *envir, and edit), or
  878.     3. is executed as a command (in xi), or
  879.     4. is used in a contains or has pattern match as either
  880.        the pattern or the target string, or
  881.     5. is an argument in a call to any built-in function
  882.        except *escape_symbols.
  883.  
  884.   In normal  evaluation, the string is scanned from left to right
  885. until a variable name or function call is found.  If the variable
  886. name has been assigned a value (even by declaration), the name is
  887. replaced by  the value.  Otherwise the name remains.  In the case
  888. of a  function call,  the arguments  (if any)  are evaluated, the
  889. function is  performed,  and  the  returned  value  (if  any)  is
  890. substituted for the name and arguments.
  891.  
  892.   In scanning  for a variable name, RAP takes the longest stretch
  893. of characters  that could legally constitute a name, and does not
  894. examine shorter subsets. Thus, if #chapter is 4 and #c is 186000,
  895. evaluation of  the string   "Beginning of chapter #chapter" turns
  896. it  into  "Beginning  of  chapter 4",  not  "Beginning of chapter
  897. 186000hapter". If there is no variable #chapter, no  substitution
  898. takes  place,  and  the  string  remains  "Beginning  of  chapter
  899. #chapter" after evaluation.
  900.  
  901.   As soon  as any  substitution has  occurred, the  scan  pointer
  902. backs up  one character  from the  beginning of  the new material
  903. (unless that  material is already at the beginning of the string)
  904. and the  scan resumes.   This  process continues  until the  scan
  905. pointer reaches the end of the string.
  906.  
  907.   If a  variable or  function name is preceded by a backslash, it
  908. is not  evaluated.   More  precisely,  it  is  not  evaluated  if
  909. immediately preceded by an odd number of backslashes.
  910.  
  911.   In final  evaluation, one pass is made through the string.  Any
  912. unpaired  backslashes  are  removed;  pairs  of  backslashes  are
  913. replaced by  single ones.   A  single backslash at the end of the
  914. string in  a t or write argument is noted as a signal to suppress
  915. the newline after the string, and is removed.
  916.  
  917.   Since output operations turn double backslashes to single ones,
  918. input operations  do the reverse.  This applies in a, ah, as, and
  919. read operations.   With  respect to backslashes, input and output
  920. operations are  complementary.  The input process precedes any \,
  921. $, #, or * symbol in the input string with a backslash.
  922.  
  923.   The *final_eval  and *escape_symbols  functions are provided to
  924. allow  programmer   access  to   these  evaluation  and  escaping
  925. processes.   *Final_eval takes  a string  and subjects  it to the
  926. same normal  and  final  evaluation  processes  described  above.
  927. *Final_eval returns  the same  thing that  a  t  statement  would
  928. display.   Similarly, *escape_symbols takes a string and performs
  929. the same escaping (of \, #, $, and * characters) as would be done
  930. by an a statement.
  931.  
  932. 12.8 Pattern matching
  933.  
  934.   Two special string comparison operators allow pattern matching;
  935. these are has and contains.  Each one tests to see if a specified
  936. pattern appears as part of a source string, and results in a 1 or
  937. 0 depending on the success of the match.
  938.  
  939.   The contains  operation also  has the  side-effect of assigning
  940. the variables  $match, $left,  and $right  equal to  the  matched
  941. string and its left- and right- context.  Both the pattern string
  942. and the  source string  are fully  evaluated before matching, and
  943. the  side-effect   strings  undergo   escaping  before  they  are
  944. assigned.
  945.  
  946.   The patterns can be constructed of ordinary text characters and
  947. the following  special characters,  which are  described in  more
  948. detail in section 5.4:
  949.  
  950.       
  951.       pattern                   matches
  952.       -------                   -------
  953.       .                         any character
  954.       ^                         beginning of line
  955.       $                         end of line
  956.       x*                        zero or more occurrences of x
  957.                                 (or the specified character)
  958.       [ ... ]  and  [^... ]     character classes
  959.       \t                        a tab character
  960.       \b                        a backslash
  961.  
  962.   In a contains operation, if the pattern matches the string, the
  963. variables $match,  $left, and  $right are  set to  match the text
  964. matched and  the pieces  on either  side.   These  variables  are
  965. normally global,  but local copies will be used if they have been
  966. declared.   These variables are only given values when a match is
  967. successful.
  968.  
  969.   If the pattern is an empty string and the source string is not,
  970. the match  fails.  If both are empty strings, the match succeeds.
  971. If this  happens in  a contains  operation,  $left,  $right,  and
  972. $match all get the empty string.
  973.  
  974.   As with other string comparisons, the distinction between upper
  975. and lower case is normally ignored in match operations.  This can
  976. be changed  by altering the value of the built-in variable #case,
  977. or a  local variable  of the  same name.   If #case is 0, case is
  978. ignored.  If it is 1, case is taken into account.  The default is
  979. 0.
  980.  
  981. 12.9 Statements
  982.  
  983.   A simple  RAP statement typically consists of a command keyword
  984. and zero  or more arguments.  Appendix B shows the syntax of each
  985. statement, including  the required arguments.  The keyword may be
  986. followed by  a colon;  this helps  separate the  keyword from its
  987. arguments but  is otherwise ignored.  The colon may be omitted if
  988. the break  between the keyword and argument is unambiguous.  If a
  989. statement begins  with a  colon (with no keyword), the keyword of
  990. the previous statement is assumed.
  991.  
  992.   The call  and assignment  statements do  not require  keywords.
  993. Any statement beginning with a valid procedure name is assumed to
  994. be a  call; any beginning with the name of a variable is taken as
  995. an assignment.
  996.  
  997. two kinds of subprograms (procedures and functions) to manage fin
  998. chapter 14 and summarized in appendix A.
  999.  
  1000. 12.10 Flow of control
  1001.  
  1002.   RAP  provides   two  kinds   of  subprograms   (procedures  and
  1003. functions) to  manage flow  of control on a high level.  Within a
  1004. subprogram, RAP  supports the  if construct,  the loop,  and  the
  1005. menu.  These three may be nested arbitrarily.
  1006.  
  1007. The if construct
  1008.  
  1009.   The if  construct is  conventional.    It  begins  with  an  if
  1010. statement, and  ends with  an end if.   The  if statement  may be
  1011. followed by  a then  statement, whose purpose is purely cosmetic,
  1012. and a  sequence of  statements constituting  an if clause.  There
  1013. may be  zero or  more else  if clauses,  and  zero  or  one  else
  1014. clauses.
  1015.  
  1016.   If the  conditional in  the if statement is true (nonzero), the
  1017. sequence in  the if  clause is  executed.  Otherwise each else if
  1018. conditional is examined in turn (if any are present) until one is
  1019. found to  be true;  its sequence is executed.  If none of them is
  1020. true, the else clause is executed.
  1021.  
  1022. The loop construct
  1023.  
  1024.   In its  simplest form,  the loop construct begins with loop and
  1025. ends with  end loop.  When RAP reaches the end loop statement, it
  1026. branches back  to the  top of  the loop.   Arbitrary exits can be
  1027. provided with  the exit statement, and arbitrary branches back to
  1028. the top with the repeat statement.
  1029.  
  1030.   You can  branch out  of nested  loops or  menus with the exit n
  1031. statement, where n is a number.  Exit 1 exits the innermost loop,
  1032. exit 2 the next one out, and so on.  Similarly, repeat n branches
  1033. to the top of nested loops or menus.  The default n is 1.
  1034.  
  1035.   The exit and repeat statements may be modified with conditions,
  1036. as in  exit if #n > 9, or  repeat 2 if not($line has  $pat).   In
  1037. this case, the exit or repeat is performed only if the expression
  1038. after the if is nonzero.
  1039.  
  1040.   The loop statement may also appear as loop while cond.  This is
  1041. exactly the same as loop followed by exit if not (cond); in fact,
  1042. this conversion is made by the loader.
  1043.  
  1044.   Similarly,  the   end loop  statement   may  be   replaced   by
  1045. until cond.  This is exactly the same as exit if cond followed by
  1046. end loop.   The loader  makes this  conversion too.    When  this
  1047. construction  is  used,  it  should  be  remembered  that  repeat
  1048. statements branch to the top of the loop, not to this test.
  1049.  
  1050.   Two  more   forms  of  the  loop  statement  are  loop for  and
  1051. loop #n times.  The sequence
  1052.  
  1053.     loop for #n = 0 to #linecount step 10
  1054.        ...
  1055.     end loop
  1056.  
  1057. is roughly equivalent to the following sequence:
  1058.  
  1059.     #n = 0
  1060.     loop while #n <= #linecount
  1061.        ...
  1062.        #n = #n + 10
  1063.     end loop
  1064.  
  1065.   The differences  are that  the loop for  form  is  clearer  and
  1066. faster, and  that it  evaluates its arguments before entering the
  1067. loop rather  than each  time through.  Only the initial values of
  1068. the final-value argument #linecount and the increment argument 10
  1069. matter. If  the statements  inside the  loop change  the value of
  1070. #linecount, this  does not  affect the  test used  in  the  loop.
  1071. Further, if  the statements  inside the  loop change the value of
  1072. the counter  variable #n, those changes are not considered in the
  1073. comparison, and  are discarded on the next pass through the loop.
  1074. A more  exact description  of what  RAP does  internally for  the
  1075. loop for fragment above would be:
  1076.  
  1077.     #counter = 0
  1078.     #limit = #linecount
  1079.     #stepval = 10
  1080.     
  1081.     if #counter > #limit
  1082.        #n = #counter
  1083.     else
  1084.        #counter = #counter - #stepval
  1085.     
  1086.        loop while #counter < #limit[7]
  1087.           #counter = #counter + #stepval
  1088.           #n = #counter
  1089.           ...
  1090.        end loop
  1091.     end if
  1092.  
  1093. where #counter,  #limit, and  #stepval are  all internal  working
  1094. variables kept by RAP and inaccessible to your program.
  1095.  
  1096.   A simpler  variation on  the loop takes the form loop #n times.
  1097. It evaluates  its argument,  and executes  the loop the specified
  1098. number of  times.   For a  negative or zero argument, it does not
  1099. execute the  loop at all.  The statement loop #linecount times is
  1100. equivalent to  the statement loop for #counter = 1 to #linecount,
  1101. where #counter is a working variable kept by RAP and inaccessible
  1102. to your program.
  1103.  
  1104. The menu construct
  1105.  
  1106.   The menu  construct asks  a  multiple-choice  question,  offers
  1107. several alternatives,  inputs  and  validates  a  selection,  and
  1108. performs a  sequence based  on the  selection.    This  construct
  1109. begins with a menu statement and a header sequence, followed by a
  1110. number of  option sequences  and an  optional help  sequence.  It
  1111. ends with end menu.
  1112.  
  1113.   When the  menu construct  is executed,  RAP first  executes the
  1114. statements in  the header sequence.  Then it displays each option
  1115. with a  tag letter  (unless otherwise  directed), and prompts the
  1116. user for  a selection.   It  validates the selection and performs
  1117. the sequence appropriate to that selection.
  1118.  
  1119.   As with  loops, the  sequences in a menu can contain repeat and
  1120. exit statements;  these cause  branching to  the top or bottom of
  1121. the menu.
  1122.  
  1123.   An option may include an if condition.  If this condition has a
  1124. nonzero value, the option will be displayed and used normally; if
  1125. the condition  is zero, the option is omitted and unused (and not
  1126. assigned a  tag letter).   This  condition is evaluated each time
  1127. the options are displayed.
  1128.  
  1129.   Usually, RAP assigns an option letter to each option in a menu.
  1130. This may  be overridden  with the  option accept  keyword,  which
  1131. specifies one  or more  user inputs that will select that option.
  1132. In this  case, RAP  will not  generate or display a single-letter
  1133. tag.   The text specified in this statement may contain wildcards
  1134. as used  in the pattern-matching operators has and contains.  The
  1135. first option to match the user input will be selected.  Unlike in
  1136. has and  contains, the  pattern must  match the  user's  complete
  1137. input (rather than just some part of it).
  1138.  
  1139.   Even if  RAP is generating an automatic tag for the option, the
  1140. option notag keyword  can be  used to stop RAP from automatically
  1141. prepending the  tag to  the option  text.  In this case, the text
  1142.  
  1143.   RAP normally  displays a  prompt of the form, "Please select an
  1144. option (a  through x)"  after the  last option.   If  a different
  1145. prompt text  is desired,  that text can appear as the argument to
  1146. the end menu statement.  If that text contains the $tag variable,
  1147. the  value  of  the  last  automatically-generated  tag  will  be
  1148. substituted.
  1149.  
  1150. Procedures and functions
  1151.  
  1152.   RAP  supports   two  kinds  of  subprograms:    procedures  and
  1153. functions.   A function  returns a  value; a  procedure does not.
  1154. There are  numeric and string functions, differing in the type of
  1155. value they return. RAP has special built-in functions in addition
  1156. to any  defined in  a user's  program;  these  are  described  in
  1157. chapter 15.
  1158.  
  1159.   A subprogram  may take  any number of arguments. Parameters are
  1160. passed by  value.   Each calling argument is evaluated[8] and the
  1161. result  is   assigned  to  the  corresponding  parameter  in  the
  1162. subprogram.   The number  of arguments  in the  calling line must
  1163. match the number of parameters in the proc or function statement,
  1164. and for  a numeric  parameter the  argument must  be numeric.  On
  1165. return from  the subprogram,  nothing happens  to the  arguments:
  1166. you cannot pass new values back out through the parameters.
  1167.  
  1168.   The  parameters   are  treated   as  local   variables  in  the
  1169. subprogram.   The subprogram  may declare  other local variables.
  1170. All of  these go away on termination of the subprogram, except in
  1171. the top-level  procedures (init__  and main, described in section
  1172. 12.11).
  1173.  
  1174.   A function returns a value with the return statement.  The type
  1175. of value  returned (string  versus number) depends on the type of
  1176. the function.  A procedure may not return a value.
  1177.  
  1178. 12.11 Programs
  1179.  
  1180.   A RAP  program consists  of an optional sequence of code at the
  1181. beginning of the file, followed by zero or more subprograms.  One
  1182. of these  may  be  a  procedure  named  main;  this  has  special
  1183. significance to  the interpreter.   Thus  a RAP  program  may  be
  1184. formed entirely  of subprograms  (including a main procedure), or
  1185. it may  consist entirely  of loose  code  not  contained  in  any
  1186. subprogram, or  it may  be a  mixture.  Loose code is not allowed
  1187. after or between subprograms.
  1188.  
  1189.   The loader  regularizes all  this, by  taking any loose code at
  1190. the beginning of the file and inventing a procedure called init__
  1191. to hold  it.    Thus  the  interpreter  sees  any  program  as  a
  1192. collection of  procedures and  functions.  The next chapter tells
  1193. what it does to run them.
  1194.  
  1195. ____________________
  1196.  
  1197.   1 Sixteen for array names.
  1198.  
  1199.   2 That's the RETURN character, not the return command.
  1200.  
  1201.   3 Eight lines on a Sharp PC-5000, 25 lines on any other system.
  1202.  
  1203.   4 If you start RAP with the command-line argument /sharp, /ibm,
  1204. or /ansi,  RAP uses  the selected  screentype and does not do any
  1205. tests.
  1206.  
  1207.   5 SmallRAP does not support the IBM screentype.  It will run on
  1208. IBM PC's  and compatibles,  but it  doesn't use  the special  IBM
  1209. screen control  features; instead  it assumes  that  ansi.sys  is
  1210. installed.  On any computer that is not a Sharp PC-5000, SmallRAP
  1211. uses the ANSI screentype.
  1212.  
  1213.   6 The  minus sign  in -10  is a unary minus, in contrast to the
  1214. binary minus in 100 - 10.
  1215.  
  1216.   7 If  the increment  is negative,  the comparison operator used
  1217. here is  changed to  ">=" instead of "<=" (and the one earlier is
  1218. "<" instead of ">".  This allows counting down as well as up.
  1219. may contain  the built-in variable $tag, which is replaced by the
  1220. automatically-generated tag.
  1221.  
  1222.   8 There  is one  exception:  the argument to *escape_symbols is
  1223. used without evaluation.
  1224.  
  1225.  
  1226. ----------------------------------------------------------------
  1227.  
  1228. Chapter 13
  1229.  
  1230.  
  1231. THE INTERPRETER
  1232.  
  1233.  
  1234.       13.1  Loading and running
  1235.  
  1236.       13.2  File access
  1237.  
  1238.       13.3  Command-line arguments
  1239.  
  1240.       13.4  Limits
  1241.  
  1242.       13.5  Normal, small, and large RAP
  1243.  
  1244.       13.6  Memory usage
  1245.  
  1246.  
  1247. 13.1 Loading and running
  1248.  
  1249.   This chapter  describes use of the RAP interpreter (RAP.EXE and
  1250. its variants) and the associated programming environment.
  1251.  
  1252.   RAP operates  in three  distinct modes:   loading, running, and
  1253. immediate.  The loader reads a program from one or more files and
  1254. stores it  internally.   When a  program is run, this internally-
  1255. stored program  is used.   Immediate  commands are  typed by  the
  1256. user.
  1257.  
  1258. The loader
  1259.  
  1260.   The loader stores the program in a somewhat modified form.  All
  1261. comments, blank  lines, and  leading and trailing blanks and tabs
  1262. are removed.   Defined constants (in normal RAP and LargeRAP) are
  1263. replaced with  their values.    Lines  from  included  files  are
  1264. substituted for  .include lines.   Command keywords are stored as
  1265. single-byte tokens.  Arguments for the most part remain intact.
  1266.  
  1267.   The loader  checks syntax  on the  program and construct level:
  1268. that is,  it checks that for each if there is an end if, and that
  1269. any then,  else if,  or else  statements in  between are  legally
  1270. placed.     Similar  checks   are  done  for  loops,  menus,  and
  1271. subprograms.   Most of  the construct  statements are replaced by
  1272. special internal  instructions with the target addresses computed
  1273. for the  required branching.   (For  the curious, the c option in
  1274. RAP's debug  facility will  show  the  instructions  used.    See
  1275. section 10.3.)
  1276.  
  1277.   While the  program is  being loaded,  procedure calls that lack
  1278. the  call   keyword  cannot   be  distinguished  from  misspelled
  1279. keywords, since  RAP doesn't  know all  the legal procedure names
  1280. until loading  is complete.   Therefore the loader keeps track of
  1281. statements in  which it has not recognized a command keyword, and
  1282. comes back  to check  them after  loading is  done.  At that time
  1283. they are  identified either as call statements or as unrecognized
  1284. command errors.
  1285.  
  1286.   The loader  does not  parse most command arguments.  Therefore,
  1287. syntax errors in those arguments are not detected at load time.
  1288.  
  1289.   The .define, .undefine, and .include statements described below
  1290. have their effect at load time.  They are used by the loader, and
  1291. are not  themselves stored  as part  of the  internal form  of  a
  1292. loaded program.   Both  .define and .undefine may also be used in
  1293. immediate mode.
  1294.  
  1295. Defined names
  1296.  
  1297.   You can  define a symbolic constant name to be used at program-
  1298. loading time  as an  abbreviation for  a string,  by means of the
  1299. .define keyword.  Once a  name is defined, any appearance of that
  1300. name in  the program  being loaded will be replaced by the string
  1301. specified.  This is similar to the idea of a string variable, but
  1302. different in  that evaluation  takes place  while the  program is
  1303. being loaded,  instead of while it is being run.  By the time the
  1304. program has  been stored  internally, all  the symbolic  constant
  1305. names (also  called defined  names) have  been replaced  by their
  1306. values.
  1307.  
  1308.   Defined names  are used  to avoid  embedding "magic numbers" in
  1309. your  program.  For  example,  if  your  program  makes  repeated
  1310. reference to the width of a printed page, you might have repeated
  1311. occurrences of  the number 80 scattered around the program.  Some
  1312. future change  to a  132-column printer might require you to find
  1313. each occurrence  of 80  and change  it to 132, as well as perhaps
  1314. changing each 79 to a 131, and so on.
  1315.  
  1316.   If you  were to  use a defined name instead, you might have the
  1317. line
  1318.  
  1319.     .define .pagewidth 80
  1320.  
  1321. somewhere at  the beginning  of your program.  Then in the places
  1322. in your  program where  you would  have used  80, you  could  use
  1323. .pagewidth instead.   After  the .define, the loader will replace
  1324. every use  of .pagewidth,  so that  by the  time the  program  is
  1325. loaded, each  reference will  say 80  again.   This helps  in two
  1326. ways: first,  changing to a new page width only requires that you
  1327. change the number in one place.  Second, you don't have to figure
  1328. out which  occurrences of  80 refer  to the page width, and which
  1329. ones are there for some other reason and shouldn't be changed.
  1330.  
  1331.   The argument  to .define  is a  name followed by a text string.
  1332. The name  begins with  a period, followed by a letter and zero or
  1333. more letters, digits, or underscores, with a maximum length of 20
  1334. characters.   When a  string is  scanned for constant names to be
  1335. expanded, a  potential name  must match  the defined name for its
  1336. full length.   If  .TRUE is  defined as  1, .TRUER  will  not  be
  1337. converted to 1R.
  1338.  
  1339.   Symbolic constants  are only replaced as the code is loaded, or
  1340. as immediate  instructions are  typed.  If in the example above a
  1341. string that  is formed  at run time contains the name .pagewidth,
  1342. the name  will not  be replaced  with 80 when (at run time) it is
  1343. evaluated.
  1344.  
  1345.   You can  remove the  definition of  a name  with the  .undefine
  1346. directive, as  in .undefine .pagewidth.  It is legal to .undefine
  1347. a constant  that has not been defined; this has no effect.  It is
  1348. an error  to .define the same symbol twice without an intervening
  1349. .undefine.  .Define and .undefine are not supported in SmallRAP.
  1350.  
  1351. Including files
  1352.  
  1353.   The .include  keyword causes  the loader's  input stream  to be
  1354. diverted to  draw from  another file.  The loader reads and loads
  1355. lines from the second file until it reaches the end of that file,
  1356. then resumes  reading the  original file  at the  line after  the
  1357. .include statement.   This  is  one  way  of  organizing  program
  1358. portions in  different files,  and of  putting reusable  parts of
  1359. programs somewhere  so that  they can  easily be  used by several
  1360. different programs.
  1361.  
  1362.   For example, some portion of code which the programmer wants to
  1363. include in several programs could be stored in file COMMON.H, and
  1364. then referred  to in each of the programs with a statement of the
  1365. form   .include common.h.  .Include statements may be nested to a
  1366. total depth  of four  (one main file and three .include'd files).
  1367. The same  search rules are used for finding .include files as for
  1368. main program files.
  1369.  
  1370. Running a program:  the interpreter
  1371.  
  1372.   You can  cause RAP  to load  a program  without running  it, by
  1373. using the  load command.   RAP  will read and store your program,
  1374. and then  wait (in  the "immediate"  mode)  for  you  to  type  a
  1375. command.   Sometimes this is useful when debugging.  You can then
  1376. start your program by typing run.
  1377.  
  1378.   An easier  way is  to load  and start  your program in a single
  1379. command, by  specifying the program name in your run command.  As
  1380. soon as  RAP finishes  loading the  program, it moves directly to
  1381. the "running" mode and starts running it.
  1382.  
  1383.   The interpreter  runs a  program by  first clearing  the symbol
  1384. table of  any variables.   Then  it looks  for a procedure called
  1385. init__ (init  followed by two underscores), created by the loader
  1386. and holding  any "loose  code" found  before the first procedure.
  1387. If init__  is found,  it is  executed.   When init__ is done, any
  1388. variables it  used are  kept.    Next  the  loader  looks  for  a
  1389. procedure called  main, which  only exists  if the programmer has
  1390. created it.   If  this is  found, it  too is  run.  If neither an
  1391. init__ nor a main procedure can be found, RAP informs the user.
  1392.  
  1393. Immediate mode:  getting commands from the keyboard
  1394.  
  1395.   If a program finishes without sending control back to DOS (with
  1396. bye) or  on to  another RAP  program (with  run) or  an  external
  1397. program (with  xchain), the user sees an asterisk prompt.  RAP is
  1398. then in  immediate mode.    In  this  mode,  the  user  can  type
  1399. individual commands and RAP will execute them.
  1400.  
  1401.   In general, simple statements (as defined in appendix B) may be
  1402. used in immediate mode, while statements that form constructs may
  1403. not.   The exceptions  are r  (remark), return, and xi, which are
  1404. not allowed  in immediate  mode.  Note that a call to a procedure
  1405. is legal,  as is  a t  or  assignment  statement  whose  argument
  1406. includes an embedded function call.
  1407.  
  1408. 13.2 File access
  1409.  
  1410.   RAP accesses  files in  the loading stage (for main program and
  1411. include files)  and during  execution (for data files and editing
  1412. of program files).  In both cases, RAP supports the use of a path
  1413. list, as  seen in  the DOS  path variable.   The  string variable
  1414. $path is assigned the current value of the DOS path variable when
  1415. RAP starts  up; this  string variable  is then  used in  any file
  1416. access attempts.   You  may assign $path a different value if you
  1417. want a  different path list, and a subprogram may declare a local
  1418. copy of $path different from the global one.
  1419.  
  1420.   The loader and the edit command use paths as follows:
  1421.  
  1422. 1. If the file name provided contains a colon or a backslash, RAP
  1423.    doesn't use a path.  It assumes that the name contains its own
  1424.    directory information,  and attempts  to access  the  file  as
  1425.    named.
  1426.  
  1427. 2. If the  file name  contains no  colon or  backslash, RAP first
  1428.    tries the  current directory,  then each directory in the path
  1429.    list until the file is found or the list is exhausted.
  1430.  
  1431. 3. In either  case, in any directory where it searches, RAP first
  1432.    looks for a file with the exact name specified.  If it doesn't
  1433.    find it  and the name has no extension, it appends .RAP to the
  1434.    name and  looks again.   (In SmallRAP, it tries appending .RPS
  1435.    first, then  .RAP.   In LargeRAP,  it tries  .RPL first,  then
  1436.    .RAP)   If the  name ends  with a period and no extension, RAP
  1437.    does not append one.
  1438.  
  1439. Figure 13.1  shows several run statements and the files which RAP
  1440. would look for on each one, given a $path of C:\\RAP;C:\\BIN; .
  1441.  
  1442.      
  1443.                   Figure 13.1   Path searching
  1444.  
  1445. run statement       files tried (in the order shown)
  1446.                     where $path is C:\\RAP;C:\\BIN;
  1447.  
  1448. run hello           HELLO in current directory
  1449.                     HELLO.RPS in current directory
  1450.                             (SmallRAP  only)
  1451.                     HELLO.RPL in current directory
  1452.                             (LargeRAP only)
  1453.                     HELLO.RAP in current directory
  1454.                     C:\RAP\HELLO
  1455.                     C:\RAP\HELLO.RPS (SmallRAP only)
  1456.                     C:\RAP\HELLO.RPL (LargeRAP only)
  1457.                     C:\RAP\HELLO.RAP
  1458.                     C:\BIN\HELLO
  1459.                     C:\BIN\HELLO.RPS (SmallRAP only)
  1460.                     C:\BIN\HELLO.RPL (LargeRAP only)
  1461.                     C:\BIN\HELLO.RAP
  1462.  
  1463. run hello.          HELLO in current directory
  1464.                     C:\RAP\HELLO
  1465.                     C:\BIN\HELLO
  1466.  
  1467. run \\rap\\hello.rap              \RAP\HELLO.RAP on current drive
  1468.  
  1469. run .\\hello        HELLO in current directory[1]
  1470.                     HELLO.RPS in curr dir. (SmallRAP)
  1471.                     HELLO.RPL in curr dir. (LargeRAP)
  1472.                     HELLO.RAP in current dir.
  1473.  
  1474. run c:hello         HELLO in current dir. on C:
  1475.                     HELLO.RPS in curr dir. on C:
  1476.                             (SmallRAP only)
  1477.                     HELLO.RPL in current dir. on C:
  1478.                             (LargeRAP only)
  1479.                     HELLO.RAP in curr dir. on C:
  1480.      
  1481.  
  1482.   The use  of paths  is similar  for data  files accessed in read
  1483. mode by  *open, *existf,  and *findpath,  except that  the  .RAP,
  1484. .RPS, and  .RPL extensions are not appended.  In write and append
  1485. modes, *existf  and *findpath  search by  the same rules but only
  1486. look for  files which  are writable.  *Open does not use paths in
  1487. write or append mode.
  1488.  
  1489.   RAP uses  paths for  xcall and  xchain commands  as well.   For
  1490. these, it  tries appending  .COM or .EXE if the file is not found
  1491. as named.   RAP  tries the  file as  named, the  file with a .COM
  1492. extension, and  the file  with a .EXE extension in each directory
  1493. of the path in turn.
  1494.  
  1495. 13.3 Command-line arguments
  1496.  
  1497.   The most  common form  of the command line for RAP has just one
  1498. argument, the name of the program to be run.  We see this in
  1499.  
  1500.     rap hello.rap
  1501.  
  1502.   In addition  to the  program name,  you  can  use  command-line
  1503. options to  control certain  aspects of the RAP interpreter or to
  1504. pass information  to the  RAP  program  you  are  running.    The
  1505. switches to control the interpreter include the following:
  1506.  
  1507.     /ansi         Specifies ANSI as the $screentype
  1508.     /ibm          Specifies IBM as the $screentype
  1509.                     (not applicable in SmallRAP)
  1510.     /sharp        Specifies Sharp LCD $screentype
  1511.     /trace        Enables single-step tracing
  1512.                     (in LargeRAP only)
  1513.  
  1514.   The first  command-line argument  that does  not begin  with  a
  1515. slash is assumed to be the program name.  Apart from that and the
  1516. options listed  above, any  other arguments  are treated  as user
  1517. arguments.   These are  passed to the RAP program by means of the
  1518. built-in $cmdline  variable.  Any white space (blanks or tabs) in
  1519. the command  line is  taken as  an argument  separator.  The user
  1520. arguments are  collected (with  single spaces  between them) into
  1521. one string, and the $cmdline variable is assigned this value.  If
  1522. there are  no user  arguments,  the  $cmdline  variable  contains
  1523. nothing.
  1524.  
  1525.   If the command used to start RAP is
  1526.  
  1527.     rap /ansi myprog one two three
  1528.  
  1529. then RAP  runs the  program MYPROG (or MYPROG.RAP, MYPROG.RPS, or
  1530. MYPROG.RPL),  using   ANSI  for  the  screentype,  and  assigning
  1531. $cmdline the  value  one  two  three.    The  interpreter-control
  1532. switches can  appear anywhere  in the  line; they will be removed
  1533. before $cmdline is assigned a value.  Thus
  1534.  
  1535.     rap myprog one /ansi two three
  1536.  
  1537. has exactly the same effect as the previous example.
  1538.  
  1539.   When one  RAP program  chains to another using run, it can pass
  1540. information to  it through  this same $cmdline variable by simply
  1541. assigning it the desired text value.  This value will survive the
  1542. loading process,  and will  be available  in $cmdline  to the new
  1543. program.
  1544.  
  1545. 13.4 Limits
  1546.  
  1547.   Figure 13.2  summarizes  RAP's  limits.    While  there  is  no
  1548. specific limit  on the  depth of nested calls to subprograms, the
  1549. system stack  may quietly  overflow at  around 10-20  deep.   RAP
  1550. supports recursion,  but deep recursion is likely to overflow the
  1551. stack.  This is particularly true in SmallRAP and LargeRAP, which
  1552. use fixed-size stacks.
  1553.  
  1554.      
  1555.                     Figure 13.2   RAP Limits
  1556.  
  1557.     filename length               64 characters
  1558.     files open with *open         8 (4 in SmallRAP)[2]
  1559.     include-file nesting          3 deep
  1560.     menu options                  26
  1561.     normal variable names         20 characters
  1562.     array variable names          17 characters
  1563.     nested subprogram calls       No specific limit (but see text)
  1564.     numbers                       -2147483640 to 2147483640
  1565.     program length                varies (see section 13.5)
  1566.     line length when              255 characters
  1567.       reading files                 (Any more are left for the next
  1568.                                     read; this is not an error.)
  1569.     statement length              255 chars (with all continuations)
  1570.     string length                 255 characters
  1571.      
  1572.  
  1573.   There is  no specific  limit on  program size  other than  that
  1574. imposed by  memory.   In SmallRAP  and normal  RAP, up  to 64K is
  1575. available to  hold your  program, your  data,  and  the  internal
  1576. tables and  stacks that  RAP constructs.   If your program is too
  1577. big to  load, RAP  will tell you during loading.  If your program
  1578. loads but  RAP runs  out of  "heap" memory  (used for  variables)
  1579. during execution,  RAP will  tell you  it is out of space.  If it
  1580. runs  out  of  "stack"  memory  (used  internally  for  calls  to
  1581. subprograms), the results may vary.
  1582.  
  1583.   LargeRAP, described  in the next section, is not subject to the
  1584. 64K limit.   It  can use  whatever memory  your system has, up to
  1585. 640K.
  1586.  
  1587. 13.5 Normal, small, and large RAP
  1588.  
  1589.   Three models  of RAP are provided on the RAP distribution disk.
  1590. These are  normal  RAP  (RAP.EXE),  SmallRAP  (SMALLRAP.EXE)  and
  1591. LargeRAP  (LARGERAP.EXE).     Normal  RAP  will  serve  for  most
  1592. purposes; the  other two models are provided for situations where
  1593. memory constraints are a problem.
  1594.  
  1595. SmallRAP
  1596.  
  1597.   SmallRAP is  a subset  of the  RAP language,  with some  of the
  1598. less-often-used features  removed but most of the good ones still
  1599. intact.   The SMALLRAP.EXE  interpreter is therefore smaller than
  1600. the normal  one.   It also uses memory differently.  As a result,
  1601. SmallRAP leaves  much more  memory unused and available for other
  1602. programs that  it may call.  This lets SmallRAP programs run on a
  1603. 128K Sharp PC-5000 and use DOS commands and external programs, as
  1604. long as the external programs are not too large.
  1605.  
  1606. LargeRAP
  1607.  
  1608.   In contrast,  LargeRAP allows  larger programs than normal RAP.
  1609. LargeRAP programs  and data  can total more than 64K, though they
  1610. run somewhat  more slowly.   Few  programs should need to be this
  1611. big, and  most programs  that come close can be profitably broken
  1612. into two  or more  smaller programs.  Still, there are some giant
  1613. RAP programs and so there is an interpreter to handle them.
  1614.  
  1615.   Appendix E  lists the  differences between  normal RAP  and the
  1616. other two models.
  1617.  
  1618. 13.6 Memory usage
  1619.  
  1620.   Normal RAP occupies about 105K bytes of memory.[3] This size is
  1621. fixed; it  does not vary with the size of the RAP program or data
  1622. you create.   This  space includes  the RAP.EXE interpreter and a
  1623. large (64K)  data area  which holds the user's RAP program, data,
  1624. and stack.   Most  of this  data area is usually empty, but it is
  1625. still reserved.
  1626.  
  1627.   SmallRAP occupies  a variable  amount of  memory, between about
  1628. 50K and  100K bytes.   The  50K minimum  holds  the  SMALLRAP.EXE
  1629. interpreter and  stack; the  variable portion  holds  the  user's
  1630. program and  data.  It grows and shrinks as needed to accommodate
  1631. the RAP  program being  run; the  memory  it  does  not  need  is
  1632. available for  running other  programs called  from  RAP.    This
  1633. feature of SmallRAP allows the xs, xchain, and xcall functions to
  1634. be used on a 128K Sharp, provided the external programs they call
  1635. are not too large.
  1636.  
  1637.   Obviously, there  is still a limit.  If some program needs 128K
  1638. to run  all by  itself, it won't be able to run along with RAP in
  1639. 128K.   Nevertheless, many small external programs, useful tools,
  1640. and DOS commands are usable with SmallRAP, even on a 128K Sharp.
  1641.  
  1642.   LargeRAP also  occupies a  variable amount  of memory,  ranging
  1643. from about  80K with  no program  loaded to  more than  500K with
  1644. really huge  programs and/or data.  For a small program, LargeRAP
  1645. will use  less total  memory than  ordinary RAP.   For  a  larger
  1646. program, it  will use  more.   For a very large program, LargeRAP
  1647. will work  where ordinary  RAP cannot  hold the  program.  That's
  1648. what it's for.
  1649.  
  1650.  
  1651. ____________________
  1652.  
  1653.   1 Unfortunately, this will not work if the current directory is
  1654. the root.   Under  MS-DOS, period (.) means the current directory
  1655. only when in a subdirectory.
  1656.  
  1657.   2 Note  that DOS  also imposes  limits on  the number  of  open
  1658. files.   The default is eight, including five predefined ones for
  1659. the console,  aux, and  printer.   You can increase the DOS limit
  1660. with a  FILES= statement  in the  CONFIG.SYS file;  see your  DOS
  1661. manual.
  1662.  
  1663.   3 Or slightly less on a 128K Sharp.
  1664.  
  1665.  
  1666. ----------------------------------------------------------------
  1667.  
  1668. Chapter 14
  1669.  
  1670.  
  1671. COMMAND DESCRIPTIONS
  1672.  
  1673.  
  1674.   Part I  described various  RAP commands  in a tutorial fashion.
  1675. This chapter  presents all  of the  RAP commands  in alphabetical
  1676. order, with  syntax descriptions  and examples.  A summary of the
  1677. commands appears  in appendix  A,  and  the  complete  syntax  in
  1678. appendix B.
  1679.  
  1680.   The syntax  descriptions shown  here for each command include a
  1681. colon after  the command.   The  colon is not required as long as
  1682. the argument  can be distinguished from the command keyword; thus
  1683. most  of  the  examples,  like  most  RAP  statements  in  actual
  1684. practice, do not include the colon.
  1685.  
  1686.  
  1687. _________________________________________________________________
  1688.  
  1689. a
  1690. _________________________________________________________________
  1691.  
  1692. Syntax
  1693.  
  1694.    a: var     
  1695.    a:
  1696.  
  1697. where var is the name of a a numeric or string variable.
  1698.  
  1699. Description
  1700.  
  1701.   The accept  statement is  used for input from the keyboard.  It
  1702. takes a  line of input and (usually) stores it in a variable.  If
  1703. the variable  name provided  is a string variable name, the input
  1704. is stored  as a  string (without  the newline).   If  that string
  1705. contains any  $, #,  *, or  \ characters,  RAP "escapes"  them by
  1706. prefixing them with backslashes.
  1707.  
  1708.   If the  argument to the a statement is a numeric variable name,
  1709. the input  from the  keyboard must  be a  number.   The specified
  1710. variable is then assigned its value.
  1711.  
  1712.   If the a statement has no argument, it gets a line of input and
  1713. discards it.
  1714.  
  1715. Examples
  1716.  
  1717.    a:$name    This inputs a line from the keyboard, and stores it
  1718.               as a string in $name.
  1719.  
  1720.    a:#pages   This inputs  a line,  parses it  as a  number,  and
  1721.               stores its value in #pages.
  1722.  
  1723.    a:         This inputs and discards a line from the keyboard.
  1724.  
  1725.  
  1726. _________________________________________________________________
  1727.  
  1728. ah                     (Not supported in SmallRAP)
  1729. _________________________________________________________________
  1730.  
  1731. Syntax
  1732.  
  1733.    ah: var    
  1734.    ah:
  1735.  
  1736. where var is the name of a a numeric or string variable.
  1737.  
  1738. Description
  1739.  
  1740.   The accept-hanging  statement is  just like  a, except  that it
  1741. returns the  cursor to  the end  of the  typed input  text on the
  1742. screen when done.
  1743.  
  1744. Examples
  1745.  
  1746.    ah:$name   This inputs a line, stores it as a string in $name,
  1747.               and puts the cursor at the end of the typed input.
  1748.  
  1749.    ah:#pages  This inputs  a line  consisting of a number, stores
  1750.               its value in #pages, and puts the cursor at the end
  1751.               of the typed input.
  1752.  
  1753.    ah:        This inputs  a line,  discards  it,  and  puts  the
  1754.               cursor at the end of the typed input.
  1755.  
  1756.  
  1757. _________________________________________________________________
  1758.  
  1759. as
  1760. _________________________________________________________________
  1761.  
  1762. Syntax
  1763.  
  1764.    as: var    
  1765.    as:
  1766.  
  1767. where var is the name of a a numeric or string variable.
  1768.  
  1769. Description
  1770.  
  1771.   The accept-single statement reads a character from the keyboard
  1772. into a variable without waiting for an Enter.  The character read
  1773. is not echoed to the screen.
  1774.  
  1775.   If the  argument to as is a string variable name, the character
  1776. read is  placed in that variable.  When that character is a $, #,
  1777. *, or  \ ,  RAP  first  "escapes"  it  by  prefixing  it  with  a
  1778. backslash; the string then holds two characters.
  1779.  
  1780.   If the  argument is a numeric variable name, the ASCII code for
  1781. the character  read is  placed in  that variable.   If  as has no
  1782. argument, the character is discarded.
  1783.  
  1784. Examples
  1785.  
  1786.    as:$key    This gets  one character  from  the  keyboard,  and
  1787.               stores it in the variable $key.
  1788.  
  1789.    as:#key    This gets  one character  from  the  keyboard,  and
  1790.               stores its ASCII code in the variable #key.
  1791.  
  1792.    as:        This gets  one character  from  the  keyboard,  and
  1793.               discards it.
  1794.  
  1795.  
  1796. _________________________________________________________________
  1797.  
  1798. bye
  1799. _________________________________________________________________
  1800.  
  1801. Syntax
  1802.  
  1803.    bye:
  1804.    bye: exit-code
  1805.  
  1806. where exit-code is a numeric expression between 0 and 255.
  1807.  
  1808. Description
  1809.  
  1810.   This command  exits the  RAP interpreter.   It  closes any open
  1811. files, and  returns the user to the operating system (or whatever
  1812. program RAP  was started  from).   If you  provide  an  exit-code
  1813. argument, this  is used as the code returned to DOS.  If not, the
  1814. code 0 is returned.
  1815.  
  1816. Example
  1817.  
  1818.    bye        Exits the RAP interpreter with a return code of 0.
  1819.  
  1820.    bye 2      Exits the RAP interpreter with a return code of 2.
  1821.  
  1822.  
  1823. _________________________________________________________________
  1824.  
  1825. c, cs (also ++, --, +=, and -=)
  1826. _________________________________________________________________
  1827.  
  1828. Syntax
  1829.  
  1830.    c:num-var = num-expr     
  1831.    c:str-var = str-expr     
  1832.    num-var = num-expr  
  1833.    str-var = str-expr  
  1834.    
  1835.    cs:num-var = number 
  1836.    cs:str-var = unquoted-string    
  1837.    
  1838.    num-var ++ 
  1839.    num-var -- 
  1840.    num-var += num-expr 
  1841.    num-var -= num-expr
  1842.  
  1843. where num-var  and str-var are numeric and string variable names,
  1844. num-expr and  str-expr are  numeric and  string expressions,  and
  1845. number and unquoted-string are what they claim to be.
  1846.  
  1847. Description
  1848.  
  1849.   The  compute  statement  does  simple  assignment,  either  for
  1850. strings or  numeric variables.   The c keyword is optional and is
  1851. not normally  used; any  line beginning  with a  variable name is
  1852. interpreted as a compute statement.  For numeric assignments, the
  1853. right-hand side  of the  equals may  contain  any  valid  numeric
  1854. expression.   For string  assignments, the right-hand side (which
  1855. is not in quotes) is evaluated before assignment.
  1856.  
  1857.   Several variations  on the  compute statement  are provided  to
  1858. help make  RAP programs faster.  These include the cs keyword and
  1859. the ++,  --, +=,  and -=  operators.   They do  not  provide  any
  1860. additional  capabilities;   they  just  save  time  for  the  RAP
  1861. interpreter by  avoiding some  of  the  overhead  of  the  normal
  1862. assignment operation, as follows:
  1863.  
  1864.   If the  expression on the right side of the equals sign is just
  1865. a number  rather than a numeric expression needing evaluation, or
  1866. if it is a string that does not contain any variables or function
  1867. calls to  be evaluated, you can use the keyword cs.  This does an
  1868. assignment without  doing all the scanning, parsing, and checking
  1869. involved in evaluating expressions.
  1870.  
  1871.   For an  assignment statement that just increases or decreases a
  1872. numeric variable  by 1,  the special  ++ and  -- operators may be
  1873. used.   The statement  #n++ is exactly equivalent to #n = #n + 1,
  1874. but it  saves RAP  the overhead  of parsing  and  evaluating  the
  1875. expression after  the equals sign, and of looking up the variable
  1876. twice.   Statements of  this form are very common in loops, where
  1877. speed  is  often  particularly  important.    Likewise,  #n--  is
  1878. equivalent to #n = #n - 1.
  1879.  
  1880.   When increasing  or decreasing a numeric variable by some value
  1881. other than  1,  the  +=  and  -=  forms  may  be  used.    Saying
  1882. #count += #n is  equivalent to  #count = #count + #n, and the RAP
  1883. interpreter carries it out just a little faster.
  1884.  
  1885. Examples
  1886.  
  1887.    c:#n = 1   
  1888.    #n = 1     
  1889.    cs:#n = 1
  1890.  
  1891. Each of these assigns the variable #n the value 1.  The second is
  1892. the most  common form;  the c: keyword is never required.  The cs
  1893. form is slightly faster than the others.
  1894.  
  1895.    $color=blue
  1896.  
  1897. This assigns string variable $color the value blue.
  1898.  
  1899.    #e = #m * #c * #c
  1900.  
  1901. This computes  a value  using a famous equation and assigns it to
  1902. #e.
  1903.  
  1904.    #line = #line + 1   
  1905.    #line ++
  1906.  
  1907. These each increase #line by one.  The second form runs faster.
  1908.  
  1909.    #line = #line + *filesize($myfile) * 4    
  1910.    #line += *filesize($myfile) * 4
  1911.  
  1912. These each  increase #line  by four  times the  value returned by
  1913. *filesize.  Again, the second form runs faster.
  1914.  
  1915.    #line--
  1916.  
  1917. This decreases #line by one.
  1918.  
  1919.    #n -= #words
  1920.  
  1921. This decreases #n by the value of #words.
  1922.  
  1923.  
  1924. _________________________________________________________________
  1925.  
  1926. ca
  1927. _________________________________________________________________
  1928.  
  1929. Syntax
  1930.  
  1931.    ca: line,col   
  1932.    ca: line   
  1933.    ca: ,col   
  1934.    ca:
  1935.  
  1936. where line and col are both numeric expressions
  1937.  
  1938. Description
  1939.  
  1940.   The cursor-address  statement places the cursor anywhere on the
  1941. screen.   It takes  two optional  arguments separated by a comma.
  1942. The first  is the  desired line (between 1 and 25 on an IBM PC, 1
  1943. and 8  on a  Sharp PC-5000  with LCD  screen); the  second is the
  1944. column (between 1 and 80).  If the line or column is omitted, the
  1945. current line  or column is assumed.  If only a column argument is
  1946. desired, it should be preceded by a comma.
  1947.  
  1948. Examples
  1949.  
  1950.    ca 15,40
  1951.  
  1952. This moves the cursor to line 15, column 40.
  1953.  
  1954.    ca 15
  1955.  
  1956. This moves the cursor to line 15, the current column.
  1957.  
  1958.    ca ,40
  1959.  
  1960. This moves the cursor to column 40 of the current line.
  1961.  
  1962.    ca #headrow,#col[#n]
  1963.  
  1964. This moves  the cursor  to the line corresponding to the value of
  1965. #headrow and  the column corresponding to the value of element #n
  1966. of the #col array.
  1967.  
  1968.    ca
  1969.  
  1970. This has  no effect  (since  it  moves  the  cursor  its  current
  1971. position).
  1972.  
  1973.  
  1974. _________________________________________________________________
  1975.  
  1976. call
  1977. _________________________________________________________________
  1978.  
  1979. Syntax
  1980.  
  1981.    [call]  procedure-name ( expr { , expr } )     
  1982.    [call]  procedure-name   expr { , expr }  
  1983.    [call]  procedure-name   
  1984.  
  1985. where each expr is an expression (string or numeric)
  1986.  
  1987. Description
  1988.  
  1989.   This statement  calls a procedure.  Its argument is the name of
  1990. the procedure,  followed by  a list  of calling  arguments.   The
  1991. calling arguments  are numeric  and/or string expressions.  These
  1992. are evaluated  (strings undergo normal string evaluation) as they
  1993. are  assigned  to  the  procedure  parameters.    The  number  of
  1994. arguments must  match the  number of  parameters defined  for the
  1995. procedure, and  each argument  must have  the same  type  as  the
  1996. corresponding parameter.
  1997.  
  1998.   The call  keyword may be omitted.  Any statement beginning with
  1999. a procedure  name is  interpreted  as  a  call  statement.    The
  2000. parentheses around the argument list may also be omitted.
  2001.  
  2002. Examples
  2003.  
  2004.    call explain("markers")
  2005.  
  2006. This calls  the  procedure  named  explain,  and  passes  it  one
  2007. argument which is the string markers.
  2008.  
  2009.    explain "markers"
  2010.  
  2011. This does  the same.   The  call keyword is not required, nor are
  2012. the parentheses.
  2013.  
  2014.    printfile($filename,"oki",#firstpage,#last,#copies)
  2015.    printfile $filename,"oki",#firstpage,#last,#copies
  2016.  
  2017. Either of  these calls  the procedure named printfile, and passes
  2018. it  the   five  arguments  shown.    The  first  two  are  string
  2019. expressions; the last three are numeric ones.
  2020.  
  2021.    printfile "myfile", *envir("PRINTER"), #last-3, +   
  2022.      #last, #people
  2023.  
  2024. This again  calls the  printfile  procedure  and  passes  it  the
  2025. arguments shown.   Note  that the  arguments may include function
  2026. calls and  arithmetic expressions.  They are evaluated before the
  2027. printfile procedure is called.
  2028.  
  2029. A string  expression in quotes may not also contain quotes inside
  2030. it, even  in an  embedded function  call.   Thus  something  like
  2031. "*envir("PRINTER").prd" ,  which has  quotes both  around it  and
  2032. inside it, is not a legal quoted string expression.
  2033.  
  2034.  
  2035. _________________________________________________________________
  2036.  
  2037. ce, cls, cl
  2038. _________________________________________________________________
  2039.  
  2040. Syntax
  2041.  
  2042.    ce:                                   (ce is  not supported in
  2043.    SmallRAP)
  2044.    cl:        
  2045.    cls:
  2046.  
  2047. Description
  2048.  
  2049.   The clear-end  statement ce  clears the screen from the current
  2050. cursor position  to the  end of  the screen,  and also clears the
  2051. typeahead  buffer.    Clear-line  (cl)  clears  from  the  cursor
  2052. position to  the end  of the  current line.   Clear-screen  (cls)
  2053. clears the  entire screen  and places  the  cursor  in  the  home
  2054. position, in the top left corner of the screen.  These statements
  2055. take no arguments.
  2056.  
  2057. Examples
  2058.  
  2059.    cls        This clears the screen
  2060.  
  2061.    cl         This clears  everything from the cursor position to
  2062.               the end of the line
  2063.  
  2064.    ce         This clears from the current cursor position to the
  2065.               end of the screen.
  2066.  
  2067.  
  2068. _________________________________________________________________
  2069.  
  2070. close
  2071. _________________________________________________________________
  2072.  
  2073. Syntax
  2074.  
  2075.    close: descriptor   
  2076.  
  2077. where descriptor is a numeric expression
  2078.  
  2079. Description
  2080.  
  2081.   This statement  closes an  open file.   Its  argument is a file
  2082. descriptor as originally assigned by *open.
  2083.  
  2084. Example
  2085.  
  2086.    close #dictionary
  2087.  
  2088. This closes  a file  which was originally opened with a statement
  2089. like #dictionary = *open($dfile)
  2090.  
  2091.  
  2092. _________________________________________________________________
  2093.  
  2094. debug                  (Not supported in SmallRAP)
  2095. _________________________________________________________________
  2096.  
  2097. Syntax
  2098.  
  2099.    debug:
  2100.  
  2101. Description
  2102.  
  2103.   This command  lets the  user examine the internal code area and
  2104. the symbol  table containing information on constants, variables,
  2105. labels, and  keywords.   Both can be helpful when debugging a RAP
  2106. program.   The user  is repeatedly  prompted to  type one  of the
  2107. following; typing  q  finally  exits  the  user  from  the  debug
  2108. subsystem.
  2109.     
  2110.     Type this:            For this effect:
  2111.     ----------            ----------------
  2112.     any variable name     show current value
  2113.     any (starred) label   show location in stored code
  2114.     .                     show all defined constants
  2115.     *                     show all labels
  2116.     #                     show all numeric variables
  2117.     $                     show all string variables
  2118.     a                     show all of symbol table
  2119.     c                     examine the code (the program)
  2120.     v                     show all variables
  2121.     q                     exit from debug subsystem
  2122.     
  2123.  
  2124.   If the  *, #,  $, a, or v option is preceded with a minus sign,
  2125. the items  shown  will  include  the  built-in  variables  and/or
  2126. function labels as well as the user-defined ones.
  2127.  
  2128.   While examining  the code area (with c), you might type 1,20 to
  2129. see lines 1-20 as stored internally, a to see all of the program,
  2130. or q to quit and return to the main debug menu.
  2131.  
  2132.  
  2133. _________________________________________________________________
  2134.  
  2135. declare
  2136. _________________________________________________________________
  2137.  
  2138. Syntax
  2139.  
  2140.    declare: var {, var}
  2141.  
  2142. where each var is a variable name
  2143.  
  2144. Description
  2145.  
  2146.   This  statement   is  used  to  create  local  variables  in  a
  2147. subprogram, or  global ones in the initial or main procedure, and
  2148. to give  them zero  or null-string initial values.  Its arguments
  2149. are variable  names separated  by commas.   If a variable name is
  2150. immediately followed  by a  subscript (a  numeric  expression  in
  2151. square brackets),  the members of an array with indexes from 0 to
  2152. that subscript are created.  Subscripts may not exceed 999.
  2153.  
  2154. Examples
  2155.  
  2156.    declare #students,#tests
  2157.  
  2158. This creates the two numeric variables shown, and gives them both
  2159. the value 0.
  2160.  
  2161.    declare $left,$match,$right
  2162.  
  2163. This creates  the three  variables shown,  and assigns  each  the
  2164. empty string  "" as  a value.   This  particular  declaration  is
  2165. highly recommended  in subprograms that use the contains facility
  2166. for pattern matching.
  2167.  
  2168.    declare #scores[50]
  2169.  
  2170. This declares  a 51-element  numeric  array  named  #scores  with
  2171. elements from #scores[0] thru #scores[50], all initialized to 0.
  2172.  
  2173.    declare $names[#classsize]
  2174.  
  2175. This declares  a string  array with  #classsize+1  elements  from
  2176. $names[0] through $names[#classsize], all set to zero.
  2177.  
  2178.  
  2179. _________________________________________________________________
  2180.  
  2181. .define                (Not supported in SmallRAP)
  2182. _________________________________________________________________
  2183.  
  2184. Syntax
  2185.  
  2186.    .define constant-name text
  2187.  
  2188. where constant-name  is a  name beginning with a period, and text
  2189. is an unquoted string
  2190.  
  2191. Description
  2192.  
  2193.   This is  a directive  to the  RAP loader  to associate  a  text
  2194. string with  a name (technically, a symbolic constant name) while
  2195. loading a program.  Its argument is the name followed by the text
  2196. string.   Once the  name is  defined, any appearance of that name
  2197. while  the   program  is   being  loaded   (or  while   immediate
  2198. instructions are being typed) will be replaced by that string.  A
  2199. name may not be .defined twice without an intervening .undefine.
  2200.  
  2201. Examples
  2202.  
  2203.    .define .TRUE 1
  2204.  
  2205. This defines the constant .TRUE equal to 1 (a string)
  2206.  
  2207.    .define .MAX_WORDLENG 20
  2208.  
  2209. This defines the constant .MAX_WORDLENG  equal to the string 20.
  2210.  
  2211.    .define .WORKFILE temp1.dat
  2212.  
  2213. This  defines   the  constant   .WORKFILE  equal  to  the  string
  2214. temp1.dat.
  2215.  
  2216.  
  2217. _________________________________________________________________
  2218.  
  2219. dir                    (Not supported in SmallRAP)
  2220. _________________________________________________________________
  2221.  
  2222. Syntax
  2223.  
  2224.    dir:       
  2225.    dir: directory-name
  2226.  
  2227. where directory-name is an unquoted string
  2228.  
  2229. Description
  2230.  
  2231.   This command  lists a  disk directory, using the dir command of
  2232. DOS.   If an  argument is  used, it is evaluated and passed on to
  2233. the system  for use  as the  dir argument.   This command assumes
  2234. that a copy of COMMAND.COM is accessible on the boot (or COMSPEC)
  2235. drive.   Note that  to pass  a backslash  on to DOS, the argument
  2236. must have a double backslash.
  2237.  
  2238. Examples
  2239.  
  2240.    dir        This lists contents of the current directory.
  2241.  
  2242.    dir *.rap  This lists  all files in the current directory with
  2243.               the extension .RAP.
  2244.  
  2245.    dir/w      This does the same, in wide format.
  2246.  
  2247.    dir \\bin  This lists contents of the \BIN directory.
  2248.  
  2249.    dir $mydir This evaluates  $mydir, and  passes its value as an
  2250.               argument to the DOS dir command.  If $mydir has the
  2251.               value \\bin,  this is  identical  to  the  previous
  2252.               example.
  2253.  
  2254.  
  2255. _________________________________________________________________
  2256.  
  2257. edit                   (Not supported in SmallRAP)
  2258. _________________________________________________________________
  2259.  
  2260. Syntax
  2261.  
  2262.    edit:      
  2263.    edit: filename
  2264.  
  2265. where filename is an unquoted string
  2266.  
  2267. Description
  2268.  
  2269.   This command  invokes an  external editor.   If you provide the
  2270. name of a file as an argument, edit searches for that file (using
  2271. the current path and the normal search rules) and passes its full
  2272. pathname to  the editor.   If  you don't  specify a filename, the
  2273. name of  the current  main program  file is  used.  When the user
  2274. exits from  the editor, the (possibly modified) main program file
  2275. is reloaded  into RAP.   This  behavior allows  you  to  edit  an
  2276. include-file without  RAP then  trying to load it as the new main
  2277. program file.
  2278.  
  2279.   The edit  command assumes  that some  editor  is  present  (and
  2280. accessible with  the current path) with the name ED.COM or ED.EXE
  2281. (or even  ED.BAT).   If this  is not so, the user may so rename a
  2282. copy of  his or  her favorite  editor.    It  also  assumes  that
  2283. COMMAND.COM is  accessible on  the boot drive, or as specified in
  2284. the COMSPEC.
  2285.  
  2286.   Like load and run, the edit command will try appending the .RAP
  2287. extension (after  trying .RPS or .RPL in SmallRAP or LargeRAP) in
  2288. order to  find the  desired file.   See  section 13.2 for more on
  2289. this.
  2290.  
  2291. Examples
  2292.  
  2293.    edit
  2294.  
  2295. This edits and reloads the current main program file
  2296.  
  2297.    edit myfile.rap
  2298.  
  2299. This edits  MYFILE.RAP, and then reloads the current main program
  2300. file.   (This is reasonable behavior if MYFILE.RAP is an include-
  2301. file referenced by the current program file).
  2302.  
  2303.  
  2304. _________________________________________________________________
  2305.  
  2306. else, else if
  2307. _________________________________________________________________
  2308.  
  2309. Syntax
  2310.  
  2311.    else:      
  2312.    else if: condition
  2313.  
  2314. where condition is a numeric expression
  2315.  
  2316. Description
  2317.  
  2318.   These  statements   introduce  alternative  clauses  in  an  if
  2319. construct.   If the  if clause condition is not met, each else if
  2320. clause condition is examined in turn, and the first clause with a
  2321. true (nonzero)  condition is  executed.   If none  of the else if
  2322. conditions  is   satisfied,  the  else  clause  (if  present)  is
  2323. executed.
  2324.  
  2325. Examples
  2326.  
  2327.     if (#n == 1)              ; this test is made first
  2328.        t:one                  ; on success we just do this
  2329.  
  2330.     else if (#n == 2)         ; if it fails, try this test
  2331.        t:two                  ; if that succeeds, do this
  2332.  
  2333.     else if (#n == 3)         ; if both fail, try this
  2334.        t:three                ; if this succeeds, do this
  2335.  
  2336.     else                      ; if no test succeeded,
  2337.        t:many                 ;  then do this
  2338.     
  2339.     end if
  2340.  
  2341.  
  2342. _________________________________________________________________
  2343.  
  2344. end if, end loop, end menu
  2345. _________________________________________________________________
  2346.  
  2347. Syntax
  2348.  
  2349.    end if:    
  2350.    end loop:  
  2351.    end menu:  
  2352.    end menu: prompt-text
  2353.  
  2354. where prompt-text is an unquoted string
  2355.  
  2356. Description
  2357.  
  2358.   These statements  mark the  ends of  the  if,  loop,  and  menu
  2359. constructs  respectively.    On  encountering  an  end loop,  RAP
  2360. branches back  to the top of the loop.  On an end if or end menu,
  2361. RAP continues  to the  next statement.  The optional argument for
  2362. the end menu  statement specifies  a string to be used instead of
  2363. the standard menu prompt.
  2364.  
  2365. Examples
  2366.  
  2367.    end if            This marks the end of an if construct.
  2368.  
  2369.    end loop          This marks the end of a loop construct.
  2370.  
  2371.    end menu          This marks the end of a menu construct.
  2372.  
  2373.    end menu:Well?    This marks the end of a menu construct
  2374.                      which will use the (rude) prompt, "Well?"
  2375.  
  2376.  
  2377. _________________________________________________________________
  2378.  
  2379. end function
  2380. _________________________________________________________________
  2381.  
  2382. Syntax
  2383.  
  2384.    end function:
  2385.  
  2386. Description
  2387.  
  2388.   This marks the end of either a numeric or string function.
  2389.  
  2390. Example
  2391.  
  2392.    end function   This marks the end of a function
  2393.  
  2394.  
  2395. _________________________________________________________________
  2396.  
  2397. end proc
  2398. _________________________________________________________________
  2399.  
  2400. Syntax
  2401.  
  2402.    end proc:
  2403.  
  2404. Description
  2405.  
  2406.   This marks  the end of a procedure.  If it is not preceded by a
  2407. return statement, the loader inserts one.
  2408.  
  2409. Example
  2410.  
  2411.    end proc
  2412.  
  2413. This marks the end of a procedure.
  2414.  
  2415.  
  2416. _________________________________________________________________
  2417.  
  2418. exit
  2419. _________________________________________________________________
  2420.  
  2421. Syntax
  2422.  
  2423.    exit :     
  2424.    exit if : condition 
  2425.    exit levels :  
  2426.    exit levels if : condition
  2427.  
  2428. where levels is a number and condition is a numeric expression
  2429.  
  2430. Description
  2431.  
  2432.   This causes  a branch  to the  end of a menu or loop construct.
  2433. It may include a number showing how many nested menus or loops to
  2434. be  exited,  and  it  may  have  a  conditional  controlling  its
  2435. execution.
  2436.  
  2437. Examples
  2438.  
  2439.    exit
  2440.  
  2441. This causes an exit from the innermost surrounding loop or menu.
  2442.  
  2443.    exit 2
  2444.  
  2445. This causes an exit from the second-to innermost surrounding loop
  2446. or menu.
  2447.  
  2448.    exit if #n >= 10
  2449.  
  2450. This evaluates  the numeric  expression  shown;  if  it  is  true
  2451. (nonzero), this  causes an  exit from  the innermost  surrounding
  2452. loop or menu.
  2453.  
  2454.    exit 3 if #done
  2455.  
  2456. This evaluates  the variable shown; if it is true (nonzero), this
  2457. causes an exit from the third innermost surrounding loop or menu.
  2458.  
  2459.  
  2460. _________________________________________________________________
  2461.  
  2462. foot
  2463. _________________________________________________________________
  2464.  
  2465. Syntax
  2466.  
  2467.    foot:      
  2468.    foot: footer-text
  2469.  
  2470. where footer-text is an unquoted string
  2471.  
  2472. Description
  2473.  
  2474.   The foot  statement notes the cursor position, sends the cursor
  2475. to the  bottom of  the screen,  writes a message there, and waits
  2476. for the  user to  press an Enter.  If an argument is given, it is
  2477. used as  the message.   If  none is  given, the  message used  is
  2478. "Press ENTER  to continue."   After  the user  presses Enter, the
  2479. message is  cleared  and  the  cursor  returns  to  its  previous
  2480. position.
  2481.  
  2482. Examples
  2483.  
  2484.    foot:
  2485.  
  2486. This writes  "Press ENTER  to continue,"  waits for  the user  to
  2487. press Enter, then continues.
  2488.  
  2489.    foot:More...
  2490.  
  2491. This writes  More..., waits  for the  user to  press Enter,  then
  2492. continues.
  2493.  
  2494.  
  2495. _________________________________________________________________
  2496.  
  2497. help
  2498. _________________________________________________________________
  2499.  
  2500. Syntax
  2501.  
  2502.    help:
  2503.  
  2504. Description
  2505.  
  2506.   This statement  marks a  help-group in  a menu  construct.  The
  2507. help-group is executed if the user types ? or help in response to
  2508. the prompt.   If  RAP reaches  the end  of the help group without
  2509. encountering an exit or repeat statement, it branches back to the
  2510. top of the menu.
  2511.  
  2512. Example
  2513.  
  2514.    help
  2515.  
  2516. This marks  the sequence  that follows  as the  help group in the
  2517. current menu construct
  2518.  
  2519.  
  2520. _________________________________________________________________
  2521.  
  2522. if
  2523. _________________________________________________________________
  2524.  
  2525. Syntax
  2526.  
  2527.    if: condition
  2528.  
  2529. where condition is a numeric expression
  2530.  
  2531. Description
  2532.  
  2533.   This statement  begins an  if  construct.    If  the  condition
  2534. expression is  nonzero, the  clause following the if statement is
  2535. executed.   Otherwise the else if and else clauses are considered
  2536. (if present).
  2537.  
  2538. Examples
  2539.  
  2540.    if  #n == 10
  2541.  
  2542. This evaluates  the  numeric  comparison  expression  shown,  and
  2543. executes the  statements in  the if  clause only  if it  is  true
  2544. (nonzero)
  2545.  
  2546.    if  #n > 10 and #i == 0
  2547.  
  2548. This is similar, with a more complex expression.
  2549.  
  2550.    if  (#n > 10) and (#i == 0)
  2551.  
  2552. This is similar.  The parentheses are optional.
  2553.  
  2554.    if  #n
  2555.  
  2556. This executes the sequence only if the variable #n is nonzero.  A
  2557. possibly clearer equivalent is
  2558.  
  2559.    if  #n <> 0
  2560.  
  2561.  
  2562. _________________________________________________________________
  2563.  
  2564. .include
  2565. _________________________________________________________________
  2566.  
  2567. Syntax
  2568.  
  2569.    .include filename
  2570.  
  2571. where filename is an unquoted string
  2572.  
  2573. Description
  2574.  
  2575.   The .include  directive  tells  the  loader  to  begin  reading
  2576. statements from another program file.  On reaching the end of the
  2577. second file,  the loader  resumes reading the original program at
  2578. the point where it left off.
  2579.  
  2580. Example
  2581.  
  2582.    .include common.rap
  2583.  
  2584. This causes the RAP loader to temporarily draw its input from the
  2585. file COMMON.RAP, effectively placing the contents of that file at
  2586. this point in the current program as loaded.
  2587.  
  2588.  
  2589. _________________________________________________________________
  2590.  
  2591. killf
  2592. _________________________________________________________________
  2593.  
  2594. Syntax
  2595.  
  2596.    killf: filename
  2597.  
  2598. where filename is an unquoted string
  2599.  
  2600. Description
  2601.  
  2602.   This command  deletes a  file.   Its argument  (which is  fully
  2603. evaluated before  use) is  the name  of the file.  Killf does not
  2604. search the  path list  or append extensions to the filename.  The
  2605. file specified should not be open.
  2606.  
  2607. Examples
  2608.  
  2609.    killf tempfile
  2610.  
  2611. This deletes a file named TEMPFILE.
  2612.  
  2613.    killf $workfile
  2614.  
  2615. This evaluates  $workfile, comes  up with a string representing a
  2616. filename (say junk001), then deletes the file (JUNK001).
  2617.  
  2618.  
  2619. _________________________________________________________________
  2620.  
  2621. list                   (Not supported in SmallRAP)
  2622. _________________________________________________________________
  2623.  
  2624. Syntax
  2625.  
  2626.    list:
  2627.  
  2628. Description
  2629.  
  2630.   This command lists the current main program file on the screen.
  2631. Note that  it lists the file as seen on the disk, not the program
  2632. as stored  internally by  RAP.  You can see the internally stored
  2633. version, with  RAP's internal  line numbers,  by using  the debug
  2634. command and the c (code) option.
  2635.  
  2636. Example
  2637.  
  2638.    list       This lists the current main program file.
  2639.  
  2640.  
  2641. _________________________________________________________________
  2642.  
  2643. load
  2644. _________________________________________________________________
  2645.  
  2646. Syntax
  2647.  
  2648.    load: filename
  2649.  
  2650. where filename is an unquoted string
  2651.  
  2652. Description
  2653.  
  2654.   This statement  reads a RAP program from a file into memory and
  2655. stores it  internally, ready  to run.   In  contrast to run, load
  2656. does not  automatically start  the program.   The argument is the
  2657. name of  the main program file.  If this is omitted or an invalid
  2658. name is supplied, the user is prompted for a valid name.
  2659.  
  2660.   Load will  search a  path list if the desired file is not found
  2661. in the current directory, and it will try appending the extension
  2662. .RAP (also .RPS or .RPL for SmallRAP or LargeRAP) if no extension
  2663. is provided.
  2664.  
  2665. Examples
  2666.  
  2667.    load myfile
  2668.  
  2669. This loads MYFILE, MYFILE.RPS, MYFILE.RPL, or MYFILE.RAP from the
  2670. current directory or some directory in the $path list, and stores
  2671. it in memory ready to run.
  2672.  
  2673.    load .\\myfile.rap
  2674.  
  2675. This loads MYFILE.RAP from the current directory into memory.
  2676.  
  2677.    load \\it\\itmain
  2678.  
  2679. This loads ITMAIN, ITMAIN.RPS, ITMAIN.RPL, or ITMAIN.RAP from the
  2680. \\IT directory.
  2681.  
  2682.    load it\\itmain
  2683.  
  2684. This loads ITMAIN, ITMAIN.RPS, ITMAIN.RPL, or ITMAIN.RAP from the
  2685. IT subdirectory in the current directory.
  2686.  
  2687.  
  2688. _________________________________________________________________
  2689.  
  2690. loop
  2691. _________________________________________________________________
  2692.  
  2693. Syntax
  2694.  
  2695.    loop:
  2696.    loop  while: condition   
  2697.    loop: count times   
  2698.    loop: for counter = start_value to end_value   
  2699.    loop: for counter = start_value to end_value step step_value
  2700.  
  2701. where condition,  count, start_value,  end_value, and  step_value
  2702. are all numeric expressions, and counter is a numeric variable.
  2703.  
  2704. Description
  2705.  
  2706.   This marks the beginning of a loop construct, which ends at the
  2707. matching end  loop  or  until  statement.    On  encountering  an
  2708. end loop or  repeat, RAP  branches back  to  this  point.    This
  2709. statement may  include a  while  test;  this  will  be  evaluated
  2710. initially and  on each  execution.   When the while expression is
  2711. zero, RAP branches to the statement following the end loop.
  2712.  
  2713.   The loop count times  form evaluates  its argument, and repeats
  2714. the loop  the specified  number of  times.    If  the  number  is
  2715. negative or zero, the loop is not executed.
  2716.  
  2717.   The first  loop for form begins  by evaluating  start_value and
  2718. end_value.  It sets an internal counter and the specified counter
  2719. variable equal to the start_value, and tests to ensure that it is
  2720. less than or equal to the end_value.  If so, it executes the body
  2721. of the  loop.   On each  subsequent pass  through  the  loop,  it
  2722. increases the  internal counter  by 1  and tests  it against  the
  2723. end_value.  If it is less, it sets the specified counter variable
  2724. to match the internal counter, and proceeds through the loop.
  2725.  
  2726.   The loop for  form with a step_value is similar, except that it
  2727. evaluates the  step_value before the first pass through the loop,
  2728. and uses  its value  instead of  1 as  the  amount  by  which  to
  2729. increase the counter.  If the step_value is negative, the test is
  2730. that the  counter is  greater than  or equal  to  the  end_value,
  2731. instead of less than or equal.  A zero step_value is not allowed.
  2732.  
  2733. Examples
  2734.  
  2735.    loop
  2736.  
  2737. This marks the beginning of a loop.
  2738.  
  2739.    loop while #n <= 10
  2740.  
  2741. This too  marks the  beginning of a loop, but this statement also
  2742. checks at  the beginning  of each pass through the loop to see if
  2743. the numeric  expression shown  is true  (nonzero).   If not,  RAP
  2744. exits from the loop.
  2745.  
  2746.    loop 10 times
  2747.  
  2748. This marks  the beginning  of a  loop which is to be executed ten
  2749. times.
  2750.  
  2751.    loop for #n = 1 to 2000000000
  2752.  
  2753. This marks a loop which may take some time to finish.
  2754.  
  2755.    loop for #n = 100 to 200 step 10
  2756.  
  2757. This marks the beginning of a loop where the variable #n is to be
  2758. varied from  an initial  value of  100 to  a final  value of 200,
  2759. increasing by 10 on each pass through the loop.
  2760.  
  2761.  
  2762. _________________________________________________________________
  2763.  
  2764. menu
  2765. _________________________________________________________________
  2766.  
  2767. Syntax
  2768.  
  2769.    menu:
  2770.  
  2771. Description
  2772.  
  2773.   This statement  marks the start of a menu construct, which ends
  2774. at the  matching end  menu statement..    It  is  followed  by  a
  2775. sequence of  code that is executed before the options in the menu
  2776. are displayed.  The menu statement takes no argument.
  2777.  
  2778. Example
  2779.  
  2780.    menu
  2781.  
  2782. This marks the start of a menu construct.
  2783.  
  2784.  
  2785. _________________________________________________________________
  2786.  
  2787. numeric function, num function
  2788. _________________________________________________________________
  2789.  
  2790. Syntax
  2791.  
  2792.    numeric function: function-name ( var { , var } )   
  2793.    numeric function: function-name  var { , var } 
  2794.    numeric function: function-name
  2795.  
  2796. where each  var is  a variable  name (string  or numeric) with no
  2797. subscript.  The keyword numeric can be abbreviated to num.
  2798.  
  2799. Description
  2800.  
  2801.   This statement marks the beginning of a numeric function, which
  2802. is a  subprogram that  returns a  number.   The arguments to this
  2803. statement are  the function  name (which begins with an asterisk)
  2804. and an  optional list  of parameters.   The  parameter list  is a
  2805. series  of   variable  names   separated  by  commas,  optionally
  2806. surrounded by  parentheses.   There is  no limit to the number of
  2807. parameters for a function.
  2808.  
  2809.   Parameter passing  is by  value.  On entry to the function, the
  2810. parameters are  declared as  local  variables  and  are  assigned
  2811. values corresponding to the values of the corresponding arguments
  2812. provided by  the caller.   On return from the function, these and
  2813. any other local variables are deleted, and nothing happens to the
  2814. calling arguments.
  2815.  
  2816. Examples
  2817.  
  2818.    numeric function *random
  2819.  
  2820. This marks  the beginning  of a  numeric function  named *random,
  2821. which takes no arguments.
  2822.  
  2823.    num function *random
  2824.  
  2825. This does the same.  The keyword "numeric" may be abbreviated.
  2826.  
  2827.    num function *square_root(#num)
  2828.  
  2829. This marks  the start  of a  numeric function named *square_root,
  2830. which expects  one argument  that is  a numeric  expression.  The
  2831. value of  that argument  will  be  assigned  to  the  "parameter"
  2832. variable #num.
  2833.  
  2834.    num function *triangle_area(#base,#side)
  2835.  
  2836. This begins  a numeric  function expecting two numeric arguments,
  2837. to be assigned to the parameter variables #base and #side.
  2838.  
  2839.    num function *wordcount($sentence)
  2840.  
  2841. This begins  a numeric  function expecting a single argument that
  2842. is a  string expression,  whose value  will be  assigned  to  the
  2843. parameter variable $sentence.
  2844.  
  2845.    num function *random()
  2846.  
  2847. This is the same as the first example.  For a function that takes
  2848. no arguments,  the parentheses  are not  required  but  they  are
  2849. allowed.
  2850.  
  2851.  
  2852. _________________________________________________________________
  2853.  
  2854. option
  2855. _________________________________________________________________
  2856.  
  2857. Syntax
  2858.  
  2859.    option [if (condition)]  [notag] : text   
  2860.    option [if (condition)]  [accept(pattern{,pattern})] : text
  2861.  
  2862. where condition  is a  numeric expression,  text is  an  unquoted
  2863. string, and  each pattern  is an  unquoted string with any commas
  2864. escaped with backslashes.  The parentheses are required as shown.
  2865.  
  2866. Description
  2867.  
  2868.   This statement marks an option group in a menu construct.  Each
  2869. option group  offers one  choice to  the user,  and contains  the
  2870. statements to be executed if that choice is taken.
  2871.  
  2872.   An option  statement may  contain a conditional expression.  If
  2873. this is  present, it  is evaluated and the option is only offered
  2874. when the  condition is  nonzero.   An option  may also contain an
  2875. accept clause  listing a number of responses that will select it.
  2876. It may  contain a  notag  keyword  that  will  prevent  RAP  from
  2877. assigning the  option a  letter.  It must contain some text to be
  2878. displayed to the user when the menu is shown.
  2879.  
  2880.   The following  examples assume  that the option statement shown
  2881. is part  of an  option group  in a menu construct, and that there
  2882. are a number of other options also to be displayed.  For the sake
  2883. of argument,  assume that the example is the second option in the
  2884. menu, so that the automatic tag letter, if assigned, is b.
  2885.  
  2886. Examples
  2887.  
  2888.    option:Sort the data by gloss
  2889.  
  2890. This introduces  an option  group which  would be  offered to the
  2891. user                                                          as,
  2892. "b - Sort the data by gloss," when the  menu is  displayed.   The
  2893. statements following  it in  the option group are executed if the
  2894. user types b in reply to the prompt.
  2895.  
  2896.    option:Save the data into $output_file_name
  2897.  
  2898. This introduces  an option  group.   The text following option is
  2899. evaluated  as   a  string   expression.     If   the   value   of
  2900. $output_file_name were  chumash.txt, then  the  option  would  be
  2901. displayed to  the user  as,  "b -Save the data into chumash.txt."
  2902. The option  group is executed if the user answers the menu prompt
  2903. with b.
  2904.  
  2905.    option accept("s","save"):Type S to save the data
  2906.  
  2907. This displays  an option labelled, "Type S to save the data," and
  2908. executes that group if the user answers the menu prompt with s or
  2909. save.
  2910.  
  2911.    option accept ("s.*"):Type S to save the data
  2912.  
  2913. This is  similar, but executes the group in response to any input
  2914. beginning with the letter s.
  2915.  
  2916.    option if (*existf($outfile,"w")):overwrite the old +    
  2917.                                          file $outfile
  2918.  
  2919. This evaluates  the expression  in parentheses.   If  it is  true
  2920. (nonzero), meaning  that the  file exists, RAP displays an option
  2921. with the  text, "b - Overwrite old file igbo.txt," (assuming that
  2922. $outfile  has   the  value  igbo.txt).    Note  the  use  of  the
  2923. continuation marker to spread this long statement over two lines.
  2924. If the  user answers  the menu  prompt with  b, RAP  executes the
  2925. option group.
  2926.  
  2927. If the  file does not exist, the value of the expression is zero,
  2928. and the  option is  not offered.   The  option group  will not be
  2929. executed regardless  of the  user's input,  and the b tag will be
  2930. assigned to the next option group.
  2931.  
  2932.    option notag:*chr(27)[1;40H$tag. Save the data
  2933.  
  2934. This example  is tricky.   The  notag keyword  prevents RAP  from
  2935. automatically prepending  the b tag on this option.  The *chr(27)
  2936. gives you an ASCII escape character, and the sequence <esc>[1;40H
  2937. tells the  ANSI driver  (for Sharp  or ANSI  screens) to move the
  2938. cursor to line 1 column 40.  The $tag variable is replaced by the
  2939. automatic tag  assigned to this line (b).  The result of all this
  2940. is that the text, "b. Save the data,"  appears on line one at the
  2941. 40th column.   The  corresponding option group is executed on a b
  2942. input from the user.
  2943.  
  2944. This kind of trick lets you put multiple menu options on a single
  2945. line.   It also  depends completely  on having  a  computer  that
  2946. responds to  ANSI codes--either  a Sharp  PC-5000 or  an  IBM  PC-
  2947. compatible with  the ANSI  driver installed.  See section 7.1 for
  2948. more on the ANSI codes.
  2949.  
  2950.    option accept("s.*") *go(1,20) Save
  2951.  
  2952. This is  similar to  the preceding example, but this one presumes
  2953. that you  have written a string function named *go that takes two
  2954. arguments like  1 and  20 and  returns a string like <esc>[1;20H.
  2955. This example  does not  display or  respond to  an automatically-
  2956. generated tag,  but just  displays the  word Save at column 20 of
  2957. line 1, and responds to any input beginning with the letter s.
  2958.  
  2959.    option accept(".*")
  2960.  
  2961. Note that  there is  no text in this option statement.  You might
  2962. include this  as the last group in your menu.  RAP will then show
  2963. an extra  blank line at the end of the menu (that is, a line with
  2964. no text).   Since  the pattern  .* means  "zero or  more  of  any
  2965. character," this pattern matches anything.  RAP would select this
  2966. option group  in response to any input from the user that did not
  2967. match one of the earlier options.
  2968.  
  2969.  
  2970. _________________________________________________________________
  2971.  
  2972. pause                  (Not supported in SmallRAP)
  2973. _________________________________________________________________
  2974.  
  2975. Syntax
  2976.  
  2977.    pause: interval
  2978.  
  2979. where interval is a numeric expression
  2980.  
  2981. Description
  2982.  
  2983.   This statement  stops the  program for  the specified interval,
  2984. between 1 and 60 seconds.  If the argument is absent or less than
  2985. one, the  interval used  will be  one second.  If the argument is
  2986. more than 60, the interval will be 60 seconds.
  2987.  
  2988. Example
  2989.  
  2990.    pause 5    stops for five seconds
  2991.  
  2992.  
  2993. _________________________________________________________________
  2994.  
  2995. poke                   (Not supported in SmallRAP)
  2996. _________________________________________________________________
  2997.  
  2998. Syntax
  2999.  
  3000.    poke: address, value
  3001.  
  3002. where address and value are both numeric expressions
  3003.  
  3004. Description
  3005.  
  3006.   This statement  stores a value at a memory location.  Its first
  3007. argument is a number representing the absolute address of a byte;
  3008. the second  is a  value between  0 and  255 to  be stored  there.
  3009. Since you  generally have  no way  of knowing what is stored at a
  3010. given address  or what  effect changing it will have, use of poke
  3011. is technical,  risky, and  very rarely  needed.  But there it is.
  3012. Let the user beware.
  3013.  
  3014. Example
  3015.  
  3016.    poke 1047,64
  3017.  
  3018. This changes  the byte  at address 1047 (decimal) to the value 64
  3019. (decimal).   Even when you do know what effect it will have (this
  3020. one turns  on the  shift lock), such code tends to be nonportable
  3021. and hard to maintain.
  3022.  
  3023.  
  3024. _________________________________________________________________
  3025.  
  3026. proc
  3027. _________________________________________________________________
  3028.  
  3029. Syntax
  3030.  
  3031.    proc: proc-name ( var { , var } )    
  3032.    proc: proc-name  var { , var }  
  3033.    proc: proc-name
  3034.  
  3035. where each  var is  a variable  name (string  or numeric) with no
  3036. subscript
  3037.  
  3038. Description
  3039.  
  3040.   This statement  marks  the  beginning  of  a  procedure.    Its
  3041. arguments  are  the  procedure  name  and  an  optional  list  of
  3042. parameters.   The parameter  list (in parentheses) is a series of
  3043. variable names separated by commas.
  3044.  
  3045.   Parameter passing  is by value.  On entry to the procedure, the
  3046. parameters are  declared as  local  variables  and  are  assigned
  3047. values corresponding to the values of the corresponding arguments
  3048. provided by  the caller.  On return from the procedure, these and
  3049. any other local variables are deleted, and nothing happens to the
  3050. calling arguments.
  3051.  
  3052. Examples
  3053.  
  3054.    proc get_file_info
  3055.  
  3056. This introduces  a procedure  named get_file_info  which takes no
  3057. arguments.
  3058.  
  3059.    proc display_help($topic)
  3060.  
  3061. This introduces  a procedure named display_help which expects one
  3062. argument, a  string expression which will be evaluated and stored
  3063. in the parameter string variable $topic.
  3064.  
  3065.  
  3066. _________________________________________________________________
  3067.  
  3068. r (and ;)
  3069. _________________________________________________________________
  3070.  
  3071. Syntax
  3072.  
  3073.    r: comment-text     
  3074.    ; comment-text
  3075.  
  3076. where comment-text  is  an  unquoted  string,  not  ending  in  a
  3077. continuation mark  (plus sign).    In  the  semicolon  form,  the
  3078. semicolon must occur either at the beginning of the line or after
  3079. a blank or tab.
  3080.  
  3081. Description
  3082.  
  3083.   A remark  is a  form of  comment.  It is ignored by the loader.
  3084. RAP also supports same-line comments:  anything following a space
  3085. and a semicolon up to the end of the line is a comment.
  3086.  
  3087. Examples
  3088.  
  3089.    r: bib.rap Bibliography program - 5/88 - version 1.3
  3090.  
  3091. This entire line is ignored when the program is loaded.
  3092.  
  3093.    #length = 66  ; standard paper length is 66 lines
  3094.  
  3095. The white  space, semicolon,  and everything  after it is ignored
  3096. when  the  program  is  loaded.    The  statement  is  loaded  as
  3097. #length = 66.
  3098.  
  3099.    t:No comment here; this is all an ordinary t statement.
  3100.  
  3101. Here the  semicolon is  not preceded  by white space, so RAP does
  3102. not treat  it as  the start  of a  comment.   There is no comment
  3103. here; this is all an ordinary t statement.
  3104.  
  3105.  
  3106. _________________________________________________________________
  3107.  
  3108. read
  3109. _________________________________________________________________
  3110.  
  3111. Syntax
  3112.  
  3113.    read: descriptor, str-var
  3114.  
  3115. where descriptor  is a numeric expression and str-var is a string
  3116. variable
  3117.  
  3118. Description
  3119.  
  3120.   This statement reads a line from a file, and stores it (without
  3121. the newline)  in a  string variable.   The  first argument is the
  3122. descriptor number  of the  file; the  second is  the name  of the
  3123. string variable.   If  the string that is read contains any $, #,
  3124. \, or  * characters,  RAP "escapes"  them by  prefixing them with
  3125. backslashes.
  3126.  
  3127.   If the line to be read from a file exceeds 255 characters, read
  3128. will  get  255  characters  and  leave  the  file's  read-pointer
  3129. pointing to  just after  the last  character read.  The next read
  3130. operation will start reading at that point.  Likewise, if a *seek
  3131. operation puts the read-pointer in the middle of a line, the next
  3132. read will start at that point.
  3133.  
  3134.   If the  read-pointer is  at the  end of  the file (that is, the
  3135. last line  in the  file has  already been  read), each subsequent
  3136. read places  the words  End of file. in  the string variable.  If
  3137. DOS reports  an error  in reading  the file,  read puts the words
  3138. File read error. in the variable.
  3139.  
  3140. Examples
  3141.  
  3142.    read #datafile,$phrase
  3143.  
  3144. This statement  reads one  line from  the  file  whose  RAP  file
  3145. descriptor number  is stored  in #datafile,  escapes any reserved
  3146. characters it  contains as described above, and stores the string
  3147. in the variable $phrase.
  3148.  
  3149.  
  3150. _________________________________________________________________
  3151.  
  3152. repeat
  3153. _________________________________________________________________
  3154.  
  3155. Syntax
  3156.  
  3157.    repeat:
  3158.    repeat if: condition     
  3159.    repeat levels  
  3160.    repeat levels if: condition
  3161.  
  3162. where levels is a number and condition is a numeric expression
  3163.  
  3164. Description
  3165.  
  3166.   This statement  is used  to branch back to the top of a loop or
  3167. menu construct.   It  may include  a number  showing which of the
  3168. enclosing nested  menus or  loops to branch to the top of, and it
  3169. may have a conditional clause controlling its execution.
  3170.  
  3171. Examples
  3172.  
  3173.    repeat
  3174.  
  3175. This causes  an unconditional  branch to the top of the innermost
  3176. surrounding loop or menu.
  3177.  
  3178.    repeat 2
  3179.  
  3180. This causes  a branch  to  the  top  of  the  second-to-innermost
  3181. surrounding loop or menu.
  3182.  
  3183.    repeat if #n >= 10
  3184.  
  3185. This evaluates  the numeric  expression  shown;  if  it  is  true
  3186. (nonzero), this  causes a  branch to  the top  of  the  innermost
  3187. surrounding loop or menu.
  3188.  
  3189.    repeat 3 if #done
  3190.  
  3191. This evaluates  the numeric  expression  shown;  if  it  is  true
  3192. (nonzero), RAP  branches  to  the  top  of  the  third  innermost
  3193. surrounding loop or menu.
  3194.  
  3195.  
  3196. _________________________________________________________________
  3197.  
  3198. return
  3199. _________________________________________________________________
  3200.  
  3201. Syntax
  3202.  
  3203.    return: num-expr    in a numeric function 
  3204.    return: str-expr    in a string function  
  3205.    return:             in a procedure
  3206.  
  3207. Description
  3208.  
  3209.   The return  statement exits  from a  subprogram,  back  to  the
  3210. calling subprogram.   Returning  from the  main  procedure  of  a
  3211. program puts RAP in the immediate mode.
  3212.  
  3213.   A procedure  may have  any number of return statements, or none
  3214. at all.   Since  a procedure  may not  return a  value, a  return
  3215. statement in a procedure may not have an argument.
  3216.  
  3217.   A function  must have  at least  one return  statement, and may
  3218. have more.   The  value to be returned appears as the argument to
  3219. the return  statement.   In a  numeric function,  this must  be a
  3220. numeric expression.   In  a string  function, it must be a string
  3221. expression; that  is, a  string variable, a string function, or a
  3222. quoted string.
  3223.  
  3224. Examples
  3225.  
  3226.    return
  3227.  
  3228. In a  procedure, this  causes a return to the calling subprogram.
  3229. This is  the only  valid form  of  the  return  statement  for  a
  3230. procedure.   In a  function, this  statement would  be  erroneous
  3231. because no value is being returned.
  3232.  
  3233.    return 7
  3234.  
  3235. In a numeric function, this returns the value 7 to be used in the
  3236. calling subprogram.   In  a string  function or  procedure,  this
  3237. statement is erroneous.
  3238.  
  3239.    return "green"
  3240.  
  3241. In a string function, this returns the string green to be used in
  3242. the calling  subprogram.   In a  numeric function or a procedure,
  3243. this is an erroneous statement.
  3244.  
  3245.    return 5+2
  3246.  
  3247. In a  numeric function,  the numeric  expression is evaluated and
  3248. the resulting 7 is returned.
  3249.  
  3250.    return "*chr(27)[#line;#col\H"
  3251.  
  3252. In a  string function,  the string  expression shown is evaluated
  3253. and the  resulting string  is returned.  Note that the evaluation
  3254. process in  this example  involves calling  a numeric function as
  3255. well as  substituting two  variables.    This  statement  is  the
  3256. complete body  of the  *go function  referred to  in  the  option
  3257. description earlier in this section.
  3258.  
  3259. Note the use of the backslash to separate the H from the variable
  3260. name #col.   It  will be  removed in  final evaluation  when this
  3261. string is  displayed to  the screen, so that what is written will
  3262. be something  like <esc>[12,60H.    If  the  backslash  had  been
  3263. omitted, RAP  would have  looked for  a variable named #colh, and
  3264. would not have produced the desired results.
  3265.  
  3266.  
  3267. _________________________________________________________________
  3268.  
  3269. rewind
  3270. _________________________________________________________________
  3271.  
  3272. Syntax
  3273.  
  3274.    rewind: descriptor
  3275.  
  3276. where descriptor is a numeric expression
  3277.  
  3278. Description
  3279.  
  3280.   This statement  moves the  pointer for an open file back to the
  3281. beginning of  the file.   Its  argument is the descriptor of that
  3282. file, as assigned by *open.
  3283.  
  3284. Example
  3285.  
  3286.    rewind #glossfile
  3287.  
  3288. This resets  the pointer  for #glossfile  to the beginning of the
  3289. file.
  3290.  
  3291.  
  3292. _________________________________________________________________
  3293.  
  3294. run
  3295. _________________________________________________________________
  3296.  
  3297. Syntax
  3298.  
  3299.    run:
  3300.    run: filename
  3301.  
  3302. where filename is an unquoted string
  3303.  
  3304. Description
  3305.  
  3306.   The run command has two forms.  With a filename, it reads a RAP
  3307. program from  the specified  file into  memory and  executes  it.
  3308. Without a  filename, it  executes a program that has already been
  3309. loaded.
  3310.  
  3311.   To execute  a program,  this command  clears any user variables
  3312. from memory,  then calls  the init__ procedure if any exists (see
  3313. section 12.11)  and then  the main  procedure if any exists.  You
  3314. can run  the main  procedure without first clearing the variables
  3315. by saying call main.
  3316.  
  3317.   Run myfile is  equivalent to  load myfile followed by run.  The
  3318. latter combination  of commands  could not  be used in a program,
  3319. since once  the load  was completed the original program would be
  3320. gone (including  the run  command), and  the interpreter would be
  3321. back in immediate mode.
  3322.  
  3323.   Run with  a filename  tries the name first in its original form
  3324. and then  with .RAP  appended.   (SmallRAP also tries .RPS before
  3325. trying .RAP;  LargeRAP tries  .RPL and  .RAP). If  neither can be
  3326. found, each  directory in  the $path is searched in the same way.
  3327. If the  file is  not found anywhere, run prompts for a valid file
  3328. name.
  3329.  
  3330. Examples
  3331.  
  3332.    run
  3333.  
  3334. This just executes the current program.
  3335.  
  3336.    run myfile
  3337.  
  3338. This loads MYFILE, MYFILE.RPS, MYFILE.RPL, or MYFILE.RAP from the
  3339. current directory  or some  directory in the $path list, and runs
  3340. it.
  3341.  
  3342.    run .\\myfile.rap
  3343.  
  3344. This loads MYFILE.RAP from the current directory and runs it.
  3345.  
  3346.    run \\it\\itmain
  3347.  
  3348. This loads ITMAIN, ITMAIN.RPS, ITMAIN.RPL, or ITMAIN.RAP from the
  3349. \\IT directory, and runs it.
  3350.  
  3351.    run it\\itmain
  3352.  
  3353. This loads ITMAIN, ITMAIN.RPS, ITMAIN.RPL, or ITMAIN.RAP from the
  3354. IT subdirectory in the current directory, and runs it.
  3355.  
  3356.  
  3357. _________________________________________________________________
  3358.  
  3359. seek
  3360. _________________________________________________________________
  3361.  
  3362. Syntax
  3363.  
  3364.    seek: descriptor , offset  
  3365.    seek: descriptor , offset , bytes    
  3366.    seek: descriptor , offset , relbytes
  3367.  
  3368. where descriptor and offset are numeric expressions
  3369.  
  3370. Description
  3371.  
  3372.   This statement  moves the  read-pointer for a data file to just
  3373. before a  specified line  or byte in the file.  Its arguments are
  3374. the file  descriptor (assigned by *open) and the desired location
  3375. in the  file.   The location is a numeric expression. An optional
  3376. third argument may be the keyword bytes or relbytes.  Bytes makes
  3377. the seek measure its distances in characters instead of lines.  A
  3378. negative argument  in bytes  mode locates the pointer relative to
  3379. the end  of the  file.   The relbytes  keyword causes  a relative
  3380. seek, measured  in bytes,  up or  down from the current position.
  3381. If bytes or relbytes is not specified, the location is assumed to
  3382. be in terms of lines from the beginning of the file.
  3383.  
  3384. Examples
  3385.  
  3386.   The first  several examples  assume that  #myfile is  open  for
  3387. reading (as by open chumash.txt,#myfile).
  3388.  
  3389.    seek #myfile,4
  3390.  
  3391. This positions  the read  pointer for #myfile to be ready to read
  3392. the fourth line.
  3393.  
  3394.    seek #myfile,1400,bytes
  3395.  
  3396. This positions the pointer to read at the 1400th byte (character)
  3397. of the  file.   The next  read statement will get everything from
  3398. the 1400th byte through the end of the line on which that byte is
  3399. found.[1]
  3400.  
  3401.    seek #myfile,-60,bytes
  3402.  
  3403. This positions  the pointer  at the 60th byte from the end of the
  3404. file.
  3405.  
  3406.    seek #myfile,-10,relbytes
  3407.  
  3408. This moves the pointer backwards ten characters
  3409.  
  3410.    seek #myfile,#help_location[#topic],bytes
  3411.  
  3412. This evaluates the numeric expression, in this case a subscripted
  3413. numeric variable, and does a seek to the corresponding byte.  The
  3414. array #help_location  might contain  an  index  pointing  to  the
  3415. starting points of each help-topic in a text file.
  3416.  
  3417.  
  3418. _________________________________________________________________
  3419.  
  3420. string function, str function
  3421. _________________________________________________________________
  3422.  
  3423. Syntax
  3424.  
  3425.    string function: function-name ( var { , var } )    
  3426.    string function: function-name  var { , var }  
  3427.    string function: function-name
  3428.  
  3429. where each  var is  a variable  name (string  or numeric) with no
  3430. subscript.  The keyword string can be abbreviated to str.
  3431.  
  3432. Description
  3433.  
  3434.   This statement  marks the beginning of a string function, which
  3435. is a  subprogram that  returns a  string.   The arguments to this
  3436. statement are  the function name (beginning with an asterisk) and
  3437. an optional list of parameters.
  3438.  
  3439.   Parameter passing  is by  value.  On entry to the function, the
  3440. parameters are  declared as  local  variables  and  are  assigned
  3441. values corresponding to the values of the corresponding arguments
  3442. provided by  the caller.   On return from the function, these and
  3443. any other local variables are deleted, and nothing happens to the
  3444. calling arguments.
  3445.  
  3446. Examples
  3447.  
  3448.    string function *go(#line,#col)
  3449.  
  3450. This statement  introduces a  string function  named  *go,  which
  3451. expects two  arguments, both  numeric expressions.  The values of
  3452. the two arguments will be stored in the parameter variables #line
  3453. and #col.
  3454.  
  3455.    string function *get_input_file_name
  3456.  
  3457. This introduces a string function which expects no arguments.
  3458.  
  3459.    str function *get_input_file_name()
  3460.  
  3461. This does  the same.  Parentheses are not required when there are
  3462. no arguments,  but they  are allowed.   The string keyword may be
  3463. abbreviated.
  3464.  
  3465.  
  3466. _________________________________________________________________
  3467.  
  3468. t, th, ts, tsh
  3469. _________________________________________________________________
  3470.  
  3471. Syntax
  3472.  
  3473.    t: text    
  3474.    th: text   
  3475.    ts: text   
  3476.    tsh: text
  3477.  
  3478. where text is an unquoted string
  3479.  
  3480. Description
  3481.  
  3482.   The type  commands cause their arguments to be displayed on the
  3483. screen.   Plain t  normally adds a newline (return and line feed)
  3484. after the  line displayed.   Th, type and hang, leaves the cursor
  3485. at the  end of  the line.   If  the string to be displayed by a t
  3486. command ends  with a  single backslash,  the newline is not added
  3487. after the line.  The result is like a th.
  3488.  
  3489.   When a  full page  of material  has been  sent  to  the  screen
  3490. without any  user input,  output from the t command stops and the
  3491. message, "Press  ENTER  to  continue,"  appears.    The  built-in
  3492. variable #paged  can be  used to  control this feature:  if it is
  3493. assigned a  value of  zero, automatic  pausing is  disabled.  Its
  3494. default value  is one.   The  th command  is not  subject to this
  3495. full-page checking.
  3496.  
  3497.   The ts  form is  similar  to  t,  but  does  not  evaluate  its
  3498. argument.  It is (very slightly) faster than t, and is equivalent
  3499. if you  are displaying  plain text  with no  embedded  variables,
  3500. function calls,  or  backslashes.    Similarly,  tsh  is  a  non-
  3501. evaluating and slightly faster version of th.
  3502.  
  3503. Examples
  3504.  
  3505.    t:Hello, world
  3506.  
  3507. This evaluates  and displays  the text,  "hello, world,"  on  the
  3508. screen, and advances the cursor to the next line.
  3509.  
  3510.    t:*proper_greeting($location), $username.
  3511.  
  3512. This evaluates  the string  expression shown,  which in this case
  3513. involves a  function call  and  a  variable  substitution.    The
  3514. resulting string  is displayed,  with  a  newline  advancing  the
  3515. cursor to the next line.
  3516.  
  3517.    th:What is your name?
  3518.  
  3519. This evaluates  and displays  the string  expression  shown,  and
  3520. displays it  on the  screen.  This statement leaves the cursor on
  3521. the same  line as  the typed material, immediately following that
  3522. material.
  3523.  
  3524.    t:What is your name?\
  3525.  
  3526. This does  the same.   The single backslash at the end turns this
  3527. into a th statement.
  3528.  
  3529.    t:A variable named \$color.
  3530.  
  3531. The displayed  text for  this is, "A variable named $color."  The
  3532. backslash before  the $  prevents RAP from replacing the variable
  3533. name $color  with its  value, and  is then  removed in  the final
  3534. evaluation pass.
  3535.  
  3536.    t:A single backslash \\ like so.
  3537.  
  3538. The displayed  text for  this is, "A single backslash \ like so."
  3539. The double  backslash is  reduced to  a single  backslash in  the
  3540. final evaluation pass.
  3541.  
  3542.    t:The gloss marker is \\$gl_marker.
  3543.  
  3544. Assuming that  $gl_marker has the value gloss, the displayed text
  3545. for this  is The gloss marker is \gloss.   The  double  backslash
  3546. does not  prevent evaluation  of the  variable name,  but  it  is
  3547. reduced to a single backslash on the final evaluation pass.
  3548.  
  3549.    ts:Hello, world!
  3550.  
  3551. This displays  (without evaluating)  the text hello, world on the
  3552. screen, and advances the cursor to the next line.
  3553.  
  3554.  
  3555. _________________________________________________________________
  3556.  
  3557. then
  3558. _________________________________________________________________
  3559.  
  3560. Syntax
  3561.  
  3562.    then:
  3563.  
  3564. Description
  3565.  
  3566.   This statement  appears just  after the  if statement  in an if
  3567. construct.  Its only purpose is cosmetic; it may be omitted.
  3568.  
  3569. Example
  3570.  
  3571.     if  (#n mod 2) == 1
  3572.     then                  ; Here it is, doing nothing
  3573.        t:#n is odd
  3574.     else
  3575.        t:#n is even
  3576.     end if
  3577.  
  3578.  
  3579. _________________________________________________________________
  3580.  
  3581. .undefine, .undef      (Not supported in SmallRAP)
  3582. _________________________________________________________________
  3583.  
  3584. Syntax
  3585.  
  3586.    .undefine constant-name  
  3587.    .undef constant-name
  3588.  
  3589. Description
  3590.  
  3591.   This directive removes a definition of a constant name that was
  3592. originally given by .define.  Subsequent appearances of that name
  3593. will then  be left  as they  are, rather  than being  replaced by
  3594. their value.  The two forms are equivalent.
  3595.  
  3596. Example
  3597.  
  3598.    .undefine .TRUE
  3599.  
  3600. This removes the definition of .TRUE.
  3601.  
  3602.  
  3603. _________________________________________________________________
  3604.  
  3605. until
  3606. _________________________________________________________________
  3607.  
  3608. Syntax
  3609.  
  3610.    until: condition    
  3611.  
  3612. where condition is a numeric expression.
  3613.  
  3614. Description
  3615.  
  3616.   This is  an alternative  to the  end loop statement.   An until
  3617. statement is  treated just  like an exit if statement followed by
  3618. end loop.
  3619.  
  3620. Example
  3621.  
  3622.     loop
  3623.        ca 1,70
  3624.        th:*time
  3625.     until *keypress       ; When the condition is true
  3626.                           ; the loop terminates
  3627.  
  3628. This program  displays and  updates the  time in  the upper right
  3629. corner of the screen until the user presses any key.
  3630.  
  3631.  
  3632. _________________________________________________________________
  3633.  
  3634. vnew                   (Not supported in SmallRAP)
  3635. _________________________________________________________________
  3636.  
  3637. Syntax
  3638.  
  3639.    vnew: var { , var } 
  3640.    vnew: $    
  3641.    vnew: #    
  3642.    vnew:
  3643.  
  3644. where each var is a variable name
  3645.  
  3646. Description
  3647.  
  3648.   This command  allows the  user to  selectively delete variables
  3649. from the  symbol table  where they  are  stored.    Its  optional
  3650. argument can  be a list of variable names, a pound sign (#), or a
  3651. dollar sign.   When  a list is provided, each name on the list is
  3652. deleted from  the table.   Using a pound sign deletes all numeric
  3653. variables; a  dollar sign  deletes all string variables.  When no
  3654. argument is  used, all  entries are  deleted.   This  command  is
  3655. seldom used in any form.
  3656.  
  3657. Examples
  3658.  
  3659.    vnew             This deletes all variables.
  3660.  
  3661.    vnew #           This deletes all numeric variables.
  3662.  
  3663.    vnew $           This deletes all string variables.
  3664.  
  3665.    vnew $color      This deletes the $color variable.
  3666.  
  3667.    vnew #a,#b,$x    This deletes the three variables shown.
  3668.  
  3669.  
  3670. _________________________________________________________________
  3671.  
  3672. vsave, vrestore        (Not supported in SmallRAP)
  3673. _________________________________________________________________
  3674.  
  3675. Syntax
  3676.  
  3677.    vsave: filename     
  3678.    vrestore: filename
  3679.  
  3680. where filename is an unquoted string
  3681.  
  3682. Description
  3683.  
  3684.   These commands  save the  current set  of global variables to a
  3685. file and  read such  a set  from a file.  Their arguments specify
  3686. the filename to be used.
  3687.  
  3688.   The variable  table is  not cleared before a vrestore.  You can
  3689. clear it,  if you  wish, by  using a  vnew before  the  vrestore.
  3690. Otherwise, the old table entries will be supplemented by the ones
  3691. read from  the file, and will only be replaced where the a global
  3692. variable has the same name as a variable in the file.
  3693.  
  3694.   The combination  of vsave,  run, and  vrestore  can  allow  one
  3695. program to  pass a  set of  variables and their values to another
  3696. program.   A simpler  way to  pass a small amount of data is with
  3697. the $cmdline  variable; for  larger amounts  of data  you can use
  3698. explicit writes to a file in one program and reads from that file
  3699. in the next.
  3700.  
  3701.   Vsave and  vrestore are  not supported  by SmallRAP.   Even  in
  3702. normal RAP and LargeRAP their use is not encouraged.
  3703.  
  3704. Examples
  3705.  
  3706.    vsave tempfile.vsv
  3707.  
  3708. This statement saves all the global variables to the TEMPFILE.VSV
  3709. file.
  3710.  
  3711.    vrestore tempfile.vsv
  3712.  
  3713. This restores them from that file.
  3714.  
  3715.  
  3716. _________________________________________________________________
  3717.  
  3718. write, wr
  3719. _________________________________________________________________
  3720.  
  3721. Syntax
  3722.  
  3723.    write: descriptor , text 
  3724.    wr: descriptor , text
  3725.  
  3726. where descriptor  is a numeric expression and text is an unquoted
  3727. string
  3728.  
  3729. Description
  3730.  
  3731.   This statement  writes text  to a  file.  Its arguments are the
  3732. file descriptor as assigned by *open, and the text to be written.
  3733. Normally, this command places a newline at the end of the text it
  3734. writes. The  newline can  be suppressed by ending the text with a
  3735. single  backslash.     The   two   forms   write   and   wr   are
  3736. interchangeable.
  3737.  
  3738. Examples
  3739.  
  3740.    write #out,Now is the time for all good men to etc.
  3741.  
  3742. This writes the text shown to the file whose descriptor is stored
  3743. in #out.
  3744.  
  3745.    wr #outfile,$marker $value
  3746.  
  3747. This evaluates  the text  shown and  writes it  to the file whose
  3748. descriptor is stored in #outfile.
  3749.  
  3750.  
  3751. _________________________________________________________________
  3752.  
  3753. xcall
  3754. _________________________________________________________________
  3755.  
  3756. Syntax
  3757.  
  3758.    xcall: program-name  [ argument-string ]
  3759.  
  3760. where program-name and argument-string are both unquoted strings.
  3761. The program-name  begins with  the first nonblank character after
  3762. the  xcall  keyword,  and  ends  with  the  first  blank  or  tab
  3763. following.
  3764.  
  3765. Description
  3766.  
  3767.   This statement  lets you call an external non-RAP program, with
  3768. arguments if  wanted.   The argument to xcall is the program name
  3769. with any  command-line arguments.    When  the  external  program
  3770. finishes, control  returns to  the RAP  program.  This command is
  3771. related to xchain, described below.
  3772.  
  3773.   Since xcall  and xchain  do not  use COMMAND.COM,  they do  not
  3774. require that  it be  present on the disk and they use less memory
  3775. to run.   Both  xcall and  xchain support path lists based on the
  3776. RAP $path  variable, and  both try  appending .COM or .EXE to the
  3777. program name if needed.
  3778.  
  3779.   Neither xcall  nor  xchain  supports  I/O  redirection  (as  in
  3780. sort <oldfile >newfile); you can use xs if you want this feature.
  3781. Likewise, neither  xcall nor  xchain can run batch programs; they
  3782. only run .COM and .EXE programs.  To run .BAT files from RAP, use
  3783. the xs command.
  3784.  
  3785.   If xcall  is unable  to call the program, the built-in variable
  3786. #result is  set to  -1.   If the  program called returns an error
  3787. code, #result is set to the value returned. Otherwise, #result is
  3788. set to zero.
  3789.  
  3790. Examples
  3791.  
  3792.    xcall arca gloss *.gly
  3793.  
  3794. This finds  and runs a program named ARCA.COM or ARCA.EXE, giving
  3795. it the  argument string gloss *.gly.  When ARCA finishes, control
  3796. returns to RAP at the next statement.
  3797.  
  3798.    xcall sort $arc_name $filespec
  3799.  
  3800. This is  similar, but the argument string is constructed from two
  3801. variables.   Everything after  the xcall  keyword  constitutes  a
  3802. string expression,  which is  fully evaluated  and then passed to
  3803. DOS.
  3804.  
  3805.    xcall command
  3806.  
  3807. This runs  a copy  of the COMMAND.COM command processor on top of
  3808. RAP.   This gives  you a normal DOS prompt, and lets you type DOS
  3809. commands interactively  and run  other programs, though with less
  3810. memory available because RAP is still loaded.  Typing exit at the
  3811. DOS prompt gets you back to the RAP program.
  3812.  
  3813.  
  3814. _________________________________________________________________
  3815.  
  3816. xchain
  3817. _________________________________________________________________
  3818.  
  3819. Syntax
  3820.  
  3821.    xchain: program-name     
  3822.    xchain: program-name  [ arguments ]
  3823.  
  3824. where program-name  and arguments are both unquoted strings.  The
  3825. program-name begins  with the  first nonblank character after the
  3826. xchain keyword, and ends at the first subsequent blank or tab, or
  3827. at the end of the line.
  3828.  
  3829. Description
  3830.  
  3831.   This statement lets you transfer control to an external non-RAP
  3832. program, with arguments if wanted.  The argument to xchain is the
  3833. program name  with any command-line arguments.  When the external
  3834. program finishes,  control does not return to the RAP program (in
  3835. contrast to xcall above).
  3836.  
  3837. Example
  3838.  
  3839.    xchain pacman
  3840.  
  3841. This transfers  control to  an external   non-RAP  program called
  3842. PACMAN.COM or  PACMAN.EXE,  accessible  via  the  current  $path.
  3843. Control does not return to RAP when PACMAN finishes.
  3844.  
  3845.  
  3846. _________________________________________________________________
  3847.  
  3848. xi
  3849. _________________________________________________________________
  3850.  
  3851. Syntax
  3852.  
  3853.    xi: text
  3854.  
  3855. where text is an unquoted string
  3856.  
  3857. Description
  3858.  
  3859.   Execute-immediate fully evaluates its argument as a string, and
  3860. then treats  the result as a RAP command to be executed.  Certain
  3861. commands cannot  be executed  on this  basis; these  include  the
  3862. statements that  begin and end procedures and functions, declare,
  3863. xi, and the statements that form constructs.
  3864.  
  3865. Example
  3866.  
  3867.    $name=color
  3868.    xi:\$$name=blue
  3869.  
  3870. The material  after the  colon undergoes  full string  evaluation
  3871. yielding $color=blue.   This is then executed as a RAP statement,
  3872. and the variable $color is given the string value blue.
  3873.  
  3874.  
  3875. _________________________________________________________________
  3876.  
  3877. xs
  3878. _________________________________________________________________
  3879.  
  3880. Syntax
  3881.  
  3882.    xs:text
  3883.  
  3884. where text is an unquoted string
  3885.  
  3886. Description
  3887.  
  3888.   The execute-system  command fully  evaluates its  argument as a
  3889. string, then  executes it  as a  DOS command  by invoking  a  new
  3890. instance of  the command  processor.  If memory permits, this may
  3891. call another  RAP program  (by invoking  another copy  of the RAP
  3892. interpreter), or  a program  in some  other  language.    The  xs
  3893. command requires  that a  copy of  COMMAND.COM be  present on the
  3894. boot drive, or accessible via COMSPEC.
  3895.  
  3896. Example
  3897.  
  3898.    xs copy *.dat $data_directory
  3899.  
  3900. The $data_directory  string variable is replaced with its value ,
  3901. and the  resulting string is passed to DOS for execution as a DOS
  3902. command.     For  instance,   if  $data_directory   were  set  to
  3903. \\data\\chumash,   the   command   passed   to   DOS   would   be
  3904. copy *.dat \data\chumash.
  3905.  
  3906.    xs sort <$file1 >$file2
  3907.  
  3908. Assuming that $file1 and $file2 hold the names of two files, this
  3909. command invokes  the DOS sort program to sort the contents of the
  3910. first, and  store the  results in the second.  Note that this I/O
  3911. redirection would not be possible with an xcall command.
  3912.  
  3913. ____________________
  3914.  
  3915.   1 Subject to the 255-character limit.
  3916.  
  3917.  
  3918. ----------------------------------------------------------------
  3919.  
  3920. Chapter 15
  3921.  
  3922.  
  3923. BUILT-IN FUNCTION DESCRIPTIONS
  3924.  
  3925.  
  3926.   RAP supports  a number  of  built-in  functions,  as  described
  3927. below.   The headings  for each  description show  the  arguments
  3928. required.   In these  headings, string1  and filename  are string
  3929. expressions which  are fully evaluated before use.  Filename is a
  3930. file name  (which may include a drive and/or path).  String2 is a
  3931. string expression  which is  not evaluated  at  all  before  use.
  3932. Num1, startpos, length, and address are numeric expressions.  All
  3933. of the  functions involving  filenames use paths in finding those
  3934. files.
  3935.  
  3936.  
  3937. _________________________________________________________________
  3938.  
  3939. *ascii
  3940. _________________________________________________________________
  3941.  
  3942. Syntax
  3943.  
  3944.    *ascii(string1)
  3945.  
  3946. Description
  3947.  
  3948.   This  function  converts  a  character  to  its  extended-ASCII
  3949. numeric equivalent,  returning a  number between  0 and 255.  Its
  3950. argument is  a string  expression.   This is fully evaluated; the
  3951. function then  returns the  numeric  ASCII  code  for  the  first
  3952. character.   If its  argument is the empty string, *ascii returns
  3953. 0.  Any other characters are ignored.
  3954.  
  3955. Example
  3956.  
  3957.    #n = *ascii($yourname)
  3958.  
  3959. Suppose for  the example  that the  value of $yourname is Zaphod.
  3960. This call  evaluates $yourname, examines the first character, and
  3961. returns 90  (the ASCII  code for  capital Z).  The variable #n is
  3962. set to 90.
  3963.  
  3964.  
  3965. _________________________________________________________________
  3966.  
  3967. *chr
  3968. _________________________________________________________________
  3969.  
  3970. Syntax
  3971.  
  3972.    *chr(num1)
  3973.  
  3974. Description
  3975.  
  3976.   This function  converts a  numeric expression between 0 and 255
  3977. into its  extended-ASCII character equivalent.  It returns a one-
  3978. character string.    An  argument  outside  of  the  0-255  range
  3979. produces an error message.
  3980.  
  3981. Examples
  3982.  
  3983.    t:*chr(7)
  3984.  
  3985. This makes  the computer  beep.  In the ASCII code, 7 corresponds
  3986. to the "bell" character.
  3987.  
  3988.    $gohome=*chr(27)[1;1H
  3989.  
  3990. This statement assigns the variable $gohome the value <esc>[1;1H,
  3991. where <esc> is the escape character (ASCII 27).  This sequence of
  3992. characters sends the cursor home (to the top left) when displayed
  3993. on an ANSI or Sharp PC-5000 screen.
  3994.  
  3995.  
  3996. _________________________________________________________________
  3997.  
  3998. *currdir               (Not supported in SmallRAP)
  3999. _________________________________________________________________
  4000.  
  4001. Syntax
  4002.  
  4003.    *currdir()
  4004.  
  4005. Description
  4006.  
  4007.   This function  reports the  current directory  (on the  current
  4008. drive).   It takes  no argument,  and  returns  a  string.    The
  4009. parentheses are  optional.   Backslashes in  the directory string
  4010. are escaped.   The  returned string always begins with a (double)
  4011. backslash.   If the  current  directory  is  the  root,  *currdir
  4012. returns just a double backslash.
  4013.  
  4014. Example
  4015.  
  4016.    $starting_dir=*currdir()
  4017.  
  4018. This determines  the current directory, and stores it in a string
  4019. variable named $starting_dir.
  4020.  
  4021.  
  4022. _________________________________________________________________
  4023.  
  4024. *currdriv              (Not supported in SmallRAP)
  4025. _________________________________________________________________
  4026.  
  4027. Syntax
  4028.  
  4029.    *currdriv()
  4030.  
  4031. Description
  4032.  
  4033.   This function  reports the  current disk  drive.   It takes  no
  4034. argument; the  parentheses are  optional.    It  returns  a  one-
  4035. character string, consisting of a single upper-case letter.
  4036.  
  4037. Example
  4038.  
  4039.    $starting_drive=*currdriv
  4040.  
  4041. This determines  the current  drive, and  stores it  in a  string
  4042. variable named $starting_drive.
  4043.  
  4044.  
  4045. _________________________________________________________________
  4046.  
  4047. *date
  4048. _________________________________________________________________
  4049.  
  4050. Syntax
  4051.  
  4052.    *date()
  4053.  
  4054. Description
  4055.  
  4056.   This function  returns the  current date  as a  string, in  the
  4057. format   Thu Nov 20 1986.   It takes no argument; parentheses are
  4058. optional.
  4059.  
  4060. Example
  4061.  
  4062.    write #outfile, Phonology summary - $username - *date
  4063.  
  4064. The call  to *date  embedded in  the string  will be  replaced by
  4065. today's date before the line is written to the specified file.
  4066.  
  4067.  
  4068. _________________________________________________________________
  4069.  
  4070. *envir
  4071. _________________________________________________________________
  4072.  
  4073. Syntax
  4074.  
  4075.    *envir(string1)
  4076.  
  4077. Description
  4078.  
  4079.   This function  returns the  current value  of a DOS environment
  4080. variable (that  is, one  set using  the DOS  set  command.    Its
  4081. argument is  the name  of the  environment variable; the returned
  4082. value is  a string containing its value.  The name is promoted to
  4083. upper case before use, for consistency with DOS.  If the variable
  4084. is not  defined, an  empty string  is returned.   If  the  string
  4085. reported by  DOS contains backslashes, they are escaped (doubled)
  4086. when input;  any *,  $, or # character is likewise escaped with a
  4087. backslash.
  4088.  
  4089. Example
  4090.  
  4091.    $comspec=*envir("COMSPEC")
  4092.  
  4093. This  example   retrieves  the   current  value  of  the  COMSPEC
  4094. environment variable, if any.  It doubles any backslashes in that
  4095. string, and  stores it  in the RAP variable named (appropriately)
  4096. $comspec.
  4097.  
  4098.  
  4099. _________________________________________________________________
  4100.  
  4101. *escape_symbols
  4102. _________________________________________________________________
  4103.  
  4104. Syntax
  4105.  
  4106.    *escape_symbols(string2)
  4107.  
  4108. Description
  4109.  
  4110.   This function  returns a string which is a copy of the argument
  4111. with all  special characters  (#, $, \, or *) it contains escaped
  4112. by prefixing  them  with  a  backslash.    The  argument  is  not
  4113. evaluated at all.
  4114.  
  4115.   This function  is very seldom used.  Occasionally it is helpful
  4116. during debugging  when you  want to  show exactly  what a  string
  4117. contains before evaluation.
  4118.  
  4119. Example
  4120.  
  4121.    t:Trying pattern *escape_symbols("\\t\\t*")    
  4122.    
  4123.    if $lineread contains "\\t\\t*" 
  4124.       t:Found it!  Right is <$right>.   
  4125.    else
  4126.       t:Not found.     
  4127.    end if
  4128.  
  4129. This is  an example  of a t: statement added to aid in debugging.
  4130. The example  will display,  "Trying pattern  \\t\\t*,"   and then
  4131. proceed with  the string-matching comparison shown.  If the first
  4132. line  had   just  said   t:Trying pattern \\t\\t*,   the   double
  4133. backslashes would  have been  reduced to single ones during final
  4134. evaluation  before   displaying  the   string.     Instead,   the
  4135. *escape_symbols function  returned the string \\\\t\\\\t\* (which
  4136. we fortunately  never  had  to  see  or  deal  with),  and  final
  4137. evaluation in  the t:  reduced it  back to  the form  shown.    A
  4138. simpler alternative to the first line would be:
  4139.  
  4140.    ts:Trying pattern \\t\\t*
  4141.  
  4142. since the ts command does not evaluate its argument at all.
  4143.  
  4144.  
  4145. _________________________________________________________________
  4146.  
  4147. *existf
  4148. _________________________________________________________________
  4149.  
  4150. Syntax
  4151.  
  4152.    *existf(filename)
  4153.    *existf(filename,access)
  4154.  
  4155. Description
  4156.  
  4157.   *Existf reports  whether a  file exists,  accessible in a given
  4158. mode. The access-mode specified may be r, w, or a.[1] If there is
  4159. no file  with the specified name accessible in the specified mode
  4160. in the  current directory,  each directory  in the  $path list is
  4161. searched in  turn.   If a  suitable file  is found anywhere, this
  4162. function returns  a nonzero number.  If the file is not found, it
  4163. returns zero.   If  the  filename  begins  with  a  backslash  or
  4164. contains a colon, the $path list is not searched.
  4165.  
  4166.   The  nonzero   number  returned  depends  on  the  access  mode
  4167. specified and  the file's accessibility.  When the mode specified
  4168. is r,  the value  returned is 4 for a read-only file, and 2 if it
  4169. is both  readable and  writable.  When the specified mode is w, a
  4170. read-only file  will not  be reported;  the value  returned for a
  4171. writable file  is again  2.   In any  case,  failure  to  find  a
  4172. suitable file results in a 0 returned value.
  4173.  
  4174. Examples
  4175.  
  4176.    if *existf("temp1")
  4177.  
  4178. This statement marks the beginning of an if construct whose first
  4179. sequence will  be executed  only if  file  TEMP1  can  be  found.
  4180. (Recall that  the above is equivalent to if *existf("temp1") <> 0
  4181. .)
  4182.  
  4183.    if *existf("temp2","w")
  4184.  
  4185. This time,  the sequence  will be executed only if the file TEMP2
  4186. exists and is writable.
  4187.  
  4188.  
  4189. _________________________________________________________________
  4190.  
  4191. *filesize              (Not supported in SmallRAP)
  4192. _________________________________________________________________
  4193.  
  4194. Syntax
  4195.  
  4196.    *filesize(filename)
  4197.  
  4198. Description
  4199.  
  4200.   This function  reports the  size of  a file  in bytes.   For an
  4201. invalid file,  it returns  -1.   If a  file has  been opened  for
  4202. writing, it  must be  closed before  the *filesize  function  can
  4203. correctly report the new length.
  4204.  
  4205. Example
  4206.  
  4207.    if *filesize($oldfile) <= *freesp("B")
  4208.  
  4209. This statement  tests whether  the file  whose name  is stored in
  4210. $oldfile will  fit in  the free space on the disk in drive B.  If
  4211. so, the  first sequence  of the  if construct  it begins  will be
  4212. executed.
  4213.  
  4214.  
  4215. _________________________________________________________________
  4216.  
  4217. *filetime              (Not supported in SmallRAP)
  4218. _________________________________________________________________
  4219.  
  4220. Syntax
  4221.  
  4222.    *filetime(filename)
  4223.  
  4224. Description
  4225.  
  4226.   This function reports the date and time of last modification of
  4227. a   file.       It    returns   a    string   in    the    format
  4228. Thu Mar 26 17:10:38 1987 .   If no file exists with the specified
  4229. name, the string Invalid file is returned.
  4230.  
  4231. Example
  4232.  
  4233.    t:The file was last modified *filetime($old_file)
  4234.  
  4235. The function  call in this line is replaced with a string showing
  4236. the date  and time  of the  file specified.   The  resulting line
  4237. might be
  4238.  
  4239.     The file was last modified Sat Jan 31 21:03:00 1988
  4240.  
  4241.  
  4242. _________________________________________________________________
  4243.  
  4244. *fileymdt              (Not supported in SmallRAP)
  4245. _________________________________________________________________
  4246.  
  4247. Syntax
  4248.  
  4249.    *fileymdt(filename)
  4250.  
  4251. Description
  4252.  
  4253.   This function reports the date and time of a file in a sortable
  4254. format.   It returns  a string  in the format 87-03-26 17:10:38 .
  4255. If  no   file  exists   with  the   specified  name,  the  string
  4256. Invalid file is returned.
  4257.  
  4258. Example
  4259.  
  4260.    if *fileymdt($text) > *fileymdt($wordlist)
  4261.  
  4262. This if  statement compares  the dates  of two files, whose names
  4263. are in  the variables  $text and $wordlist.  If the $text file is
  4264. newer than  the $wordlist  file,  the  first  clause  of  the  if
  4265. construct is executed.
  4266.  
  4267.  
  4268. _________________________________________________________________
  4269.  
  4270. *final_eval
  4271. _________________________________________________________________
  4272.  
  4273. Syntax
  4274.  
  4275.    *final_eval(string1)
  4276.  
  4277. Description
  4278.  
  4279.   This seldom-used  function forces  full string  evaluation of a
  4280. copy of  its argument.   Full evaluation includes substitution of
  4281. values  for   any  variable  names  and  function  calls  (normal
  4282. evaluation), then removal of single backslashes and conversion of
  4283. double backslashes  to  single  ones  (final  evaluation).    The
  4284. resulting string is returned.
  4285.  
  4286. Example
  4287.  
  4288.    $abc=*final_eval("The value of \$color is $color")
  4289.  
  4290. This statement causes the string in quotes to undergo full string
  4291. evaluation.  During normal evaluation, the backslash prevents the
  4292. first $color  from being  replaced with its value, but the second
  4293. $color is  replaced.   During final  evaluation, the backslash is
  4294. removed.       The   resulting    value   of   $abc   might   be,
  4295. "The value of $color is blue."
  4296.  
  4297. Note  however  that  a  subsequent  statement  like  t:$abc  will
  4298. display, "The value of blue is blue,"  since the  argument to a t
  4299. statement undergoes normal string evaluation.
  4300.  
  4301.  
  4302. _________________________________________________________________
  4303.  
  4304. *findpath
  4305. _________________________________________________________________
  4306.  
  4307. Syntax
  4308.  
  4309.    *findpath(filename)
  4310.    *findpath(filename,mode)
  4311.  
  4312. Description
  4313.  
  4314.   This function uses the current $path to find a file, then tells
  4315. you where it found it.  If it finds the file, it returns the full
  4316. pathname  of  the  file  (including  the  drive  letter  and  the
  4317. filename).   Backslashes in  that pathname  are doubled.   If the
  4318. file is not found, *findpath returns an empty string.
  4319.  
  4320.   This function  uses the  $path  list  and  access  mode  (which
  4321. defaults to r) in exactly the same way as *existf.
  4322.  
  4323. Example
  4324.  
  4325.    t:The gloss file used was *findpath($glossfile).
  4326.  
  4327. Here, RAP  evaluates $glossfile  to get a file name, and searches
  4328. the directories  named in the current path to find it.  If found,
  4329. the function call is replaced by the full path name.
  4330.  
  4331.  
  4332. _________________________________________________________________
  4333.  
  4334. *freesp                (Not supported in SmallRAP)
  4335. _________________________________________________________________
  4336.  
  4337. Syntax
  4338.  
  4339.    *freesp(drive)
  4340.  
  4341. Description
  4342.  
  4343.   This function  reports free  space on  a drive,  in bytes.  The
  4344. argument is a string, whose first character is treated as a drive
  4345. designator.  This can either be a letter or a period (meaning the
  4346. current drive).   The  rest of the string is ignored.  An invalid
  4347. drive produces a -1 return value.
  4348.  
  4349. Example
  4350.  
  4351.    if *filesize($oldfile) <= *freesp($olddrive)
  4352.  
  4353. This statement  tests whether  the file  whose name  is stored in
  4354. $oldfile will  fit in  the free  space on  the disk  in the drive
  4355. named in  $olddrive.   If  so,  the  first  sequence  of  the  if
  4356. construct it begins will be executed.
  4357.  
  4358.  
  4359. _________________________________________________________________
  4360.  
  4361. *index
  4362. _________________________________________________________________
  4363.  
  4364. Syntax
  4365.  
  4366.    *index(string1,string2)
  4367.  
  4368. Description
  4369.  
  4370.   This function locates the first occurrence of a given character
  4371. in some  string.  The first argument is the string to search; the
  4372. first character of the second argument specifies the character to
  4373. search for.   The result is a number, showing the position in the
  4374. string where  the character  was found.  Both arguments are fully
  4375. evaluated prior to use.  If the character is not found, a zero is
  4376. returned.
  4377.  
  4378. Example
  4379.  
  4380.    #n = *index("Mississippi","s")
  4381.  
  4382. This sets  #n to 3, since s is the third character in the string.
  4383. Only the first occurrence matters.
  4384.  
  4385.  
  4386. _________________________________________________________________
  4387.  
  4388. *isnumber
  4389. _________________________________________________________________
  4390.  
  4391. Syntax
  4392.  
  4393.    *isnumber(string1)
  4394.  
  4395. Description
  4396.  
  4397.   This function  reports whether a string is a decimal number.  A
  4398. number consists  of an  optional sign  and a  string  of  digits.
  4399. There may  be space  before, after,  or between  these two parts.
  4400. The number  must be  between -2147483640  and  2147483640.    The
  4401. argument to  *isnumber is  a string  expression, which  is  fully
  4402. evaluated.   If the resulting string can be parsed as a number by
  4403. the above rules, *isnumber returns 1.  Otherwise it returns 0.
  4404.  
  4405. Example
  4406.  
  4407.    if  not *isnumber($response)
  4408.  
  4409. This if  statement checks  to see whether the string in $response
  4410. is a number.  If not, the first sequence in the if clause will be
  4411. executed.
  4412.  
  4413.  
  4414. _________________________________________________________________
  4415.  
  4416. *isnumexp              (Not supported in SmallRAP)
  4417. _________________________________________________________________
  4418.  
  4419. Syntax
  4420.  
  4421.    *isnumexp(string1)
  4422.  
  4423. Description
  4424.  
  4425.   This rarely-used function reports whether a string is a numeric
  4426. expression, as  defined in  appendix B.  The argument is a string
  4427. expression, which  is fully  evaluated.   If the resulting string
  4428. can be  parsed as  a numeric  expression,  *isnumexp  returns  1.
  4429. Otherwise it returns 0.
  4430.  
  4431.   The *isnumexp  function suppresses  parser  error  messages  in
  4432. simple expressions.   Syntax  problems in complex expressions can
  4433. produce error messages as well as a zero return value.
  4434.  
  4435. Example
  4436.  
  4437.     if *isnumexp($response)
  4438.        #n = *value($response)
  4439.     else
  4440.        #n = 0
  4441.     end if
  4442.  
  4443. This if  construct checks  to see whether the string in $response
  4444. is a numeric expression.  If so, its value is computed and stored
  4445. in #n.  If not, #n becomes zero.
  4446.  
  4447.  
  4448. _________________________________________________________________
  4449.  
  4450. *keypress
  4451. _________________________________________________________________
  4452.  
  4453. Syntax
  4454.  
  4455.    *keypress()
  4456.  
  4457. Description
  4458.  
  4459.   This function  reports whether  there is  anything in the type-
  4460. ahead buffer.  It does not disturb the contents of the buffer, or
  4461. identify  the  character(s)  therein.    It  takes  no  argument.
  4462. *Keypress returns a nonzero number for yes, 0 for no.
  4463.  
  4464. Example
  4465.  
  4466.     loop
  4467.        th:*chr(7)
  4468.     until *keypress
  4469.  
  4470. This while-loop  makes the computer beep until the user presses a
  4471. key.
  4472.  
  4473.  
  4474. _________________________________________________________________
  4475.  
  4476. *memfree
  4477. _________________________________________________________________
  4478.  
  4479. Syntax
  4480.  
  4481.    *memfree()
  4482.  
  4483. Description
  4484.  
  4485.   This function reports the amount of memory (in bytes) available
  4486. for programs external to RAP.  It takes no argument.
  4487.  
  4488. Example
  4489.  
  4490.     if *memfree < #needed
  4491.        t:Sorry... there's not enough memory to run that
  4492.         :program.  It requires #needed bytes, and with RAP
  4493.         :loaded you only have *memfree available.
  4494.        return
  4495.     end if
  4496.  
  4497. This sequence  checks the available memory, and notifies the user
  4498. if there is less memory than the value noted in #needed.
  4499.  
  4500.  
  4501. _________________________________________________________________
  4502.  
  4503. *mid
  4504. _________________________________________________________________
  4505.  
  4506. Syntax
  4507.  
  4508.    *mid(string1,startpos,length)
  4509.  
  4510. Description
  4511.  
  4512.   This function takes a substring.  Its arguments are a string, a
  4513. starting position,  and a  length.   It returns  a portion of the
  4514. string,  starting  at  the  position  noted  and  of  the  length
  4515. specified.   If the  length is  zero or  the starting position is
  4516. beyond the  end of  the string, *mid returns an empty string.  If
  4517. the length is greater than the number of characters present after
  4518. the starting  point, everything  from the  starting point  on  is
  4519. taken.
  4520.  
  4521.   The *mid  function fully evaluates its argument before counting
  4522. the characters,  and escapes  special characters  in the returned
  4523. string.
  4524.  
  4525. Examples
  4526.  
  4527.    if *mid($filepath,2,1) == ":"
  4528.  
  4529. This if  statement checks  to see  if the second character of the
  4530. string stored  in $filepath is a colon; if so, the first sequence
  4531. of the if construct is executed.
  4532.  
  4533.    $rest=*mid($filepath,3,999)
  4534.  
  4535. This takes  everything from  the third  character to  the end  of
  4536. $filepath, and stores it in $rest.
  4537.  
  4538.  
  4539. _________________________________________________________________
  4540.  
  4541. *open
  4542. _________________________________________________________________
  4543.  
  4544. Syntax
  4545.  
  4546.    *open(filename)
  4547.    *open(filename,access)
  4548.  
  4549. Description
  4550.  
  4551.   This function  opens a file for reading, writing, or appending.
  4552. It takes  one or  two arguments.   The  first is  the name of the
  4553. file.   The second  argument, if  present, identifies the kind of
  4554. access desired.   This  is typically  r, w,  or  a  for  reading,
  4555. writing, or  appending.   A complete list of access modes appears
  4556. in figure  8.3.   If the  second argument is omitted, read access
  4557. only  is   assumed.    Both  arguments  undergo  complete  string
  4558. evaluation before they are used.
  4559.  
  4560.   This function  returns an  internal file  descriptor (a number)
  4561. assigned by  RAP when  the file  is opened.  Any reference to the
  4562. file while open will be done by means of that descriptor.
  4563.  
  4564.   When opening  a file  in read mode, *open searches for the file
  4565. first in  the current  directory.   If it  cannot be found there,
  4566. *open looks  in each  directory listed in the $path variable.  If
  4567. the file  is not  found in  any directory  on that list, an error
  4568. message results.
  4569.  
  4570.   When opening  a file  in any other mode, no paths are used.  If
  4571. the file  does not  exist in the current directory, it is created
  4572. there.
  4573.  
  4574.   If the  filename argument  contains a  colon or  begins with  a
  4575. backslash, (meaning  that  it  includes  drive  and/or  directory
  4576. information), then  no path  searching occurs.   The  argument is
  4577. used as provided.
  4578.  
  4579. Examples
  4580.  
  4581.    #b=*open("myfile","r")
  4582.  
  4583. This statement  opens a file named MYFILE for reading, associates
  4584. some file  descriptor number  with it,  and stores that number in
  4585. the variable  #b.    If  MYFILE  is  not  found  in  the  current
  4586. directory, RAP  searches the  current $path  list to look for it.
  4587. If the  file is  not found in any directory in the path list, RAP
  4588. displays an error message.
  4589.  
  4590.    #b=*open("myfile")
  4591.  
  4592. This does  exactly  the  same  thing.    If  no  access  type  is
  4593. specified, read-access is assumed.
  4594.  
  4595.    #phrasefile=*open($textfile,"w")
  4596.  
  4597. This opens  the file named in $textfile for writing, and stores a
  4598. descriptor for  it in  the variable  #phrasefile.  If the file is
  4599. not found  (without searching  a path), a file with the specified
  4600. name is  created in  the directory  specified in the argument (or
  4601. the current  directory as  a default).  Any prior contents of the
  4602. file are replaced.
  4603.  
  4604.    #phrasefile=*open("chumash.txt","a")
  4605.  
  4606. This statement opens CHUMASH.TXT for appending, and stores a file
  4607. descriptor for  it in  #phrasefile.   In append  mode, the  prior
  4608. contents of  the file  are not  replaced;  rather,  anything  new
  4609. written to  the file  will go  after the end of the old material.
  4610. As with  write-access, the  path is not used.  If the file is not
  4611. found in  the directory specified in the argument (or the current
  4612. directory as a default), it is created there.
  4613.  
  4614.    #phrasefile=*open("chumash.txt","x")
  4615.  
  4616. This statement  creates a  new  file  named  CHUMASH.TXT  in  the
  4617. current directory,  and opens  it for  writing.  Such a file must
  4618. not already exist, or an error message will result.
  4619.  
  4620.  
  4621. _________________________________________________________________
  4622.  
  4623. *peek                  (not supported in SmallRAP)
  4624. _________________________________________________________________
  4625.  
  4626. Syntax
  4627.  
  4628.    *peek(address)
  4629.  
  4630. Description
  4631.  
  4632.   This rare,  technical, and  seldom useful  function reports the
  4633. contents of  a byte in memory referenced by its absolute address.
  4634. Its argument is a number.  It returns a number between 0 and 255.
  4635.  
  4636. Example
  4637.  
  4638.    t:*peek(#loc)
  4639.  
  4640. This line reports the byte at absolute address #loc.
  4641.  
  4642.  
  4643. _________________________________________________________________
  4644.  
  4645. *strlen
  4646. _________________________________________________________________
  4647.  
  4648. Syntax
  4649.  
  4650.    *strlen(string1)
  4651.  
  4652. Description
  4653.  
  4654.   Reports the  length of  a string.   Its  argument is  a  string
  4655. expression.   This is  fully evaluated,  and the  length  of  the
  4656. resulting string is reported.  This function returns a number.
  4657.  
  4658. Examples
  4659.  
  4660.    #length = *strlen($yourname)
  4661.  
  4662. This sets #length to the number of characters in $yourname.
  4663.  
  4664.  
  4665. _________________________________________________________________
  4666.  
  4667. *tell
  4668. _________________________________________________________________
  4669.  
  4670. Syntax
  4671.  
  4672.    *tell(descriptor)
  4673.  
  4674. Description
  4675.  
  4676.   This function,  a complement  to the seek command,  reports the
  4677. position of  a read-pointer (or write-pointer), measured in bytes
  4678. from the  beginning  of  the  file.    Its  argument  is  a  file
  4679. descriptor number  as assigned by *open.  This function returns a
  4680. number.  An invalid descriptor argument gives an error message.
  4681.  
  4682. Example
  4683.  
  4684.    #position = *tell(#pfilnum)
  4685.  
  4686. This determines the position of the read-pointer in the file that
  4687. was opened  in some statement like #pfilnum = *open($phrasefile),
  4688. and stores this number in #position.
  4689.  
  4690.  
  4691. _________________________________________________________________
  4692.  
  4693. *time
  4694. _________________________________________________________________
  4695.  
  4696. Syntax
  4697.  
  4698.    *time()
  4699.  
  4700. Description
  4701.  
  4702.   This function returns the current time as a string, in the form
  4703. 16:22:30 .  It takes no arguments.  The parentheses are optional.
  4704.  
  4705. Example
  4706.  
  4707.     loop
  4708.        ca 1,70
  4709.        th:*time
  4710.     until *keypress
  4711.  
  4712. This program  displays the  time in the upper right corner of the
  4713. screen, updating  it as  quickly as  it can,  until you press any
  4714. key.  The last line is equivalent to until *keypress <> 0 .
  4715.  
  4716.  
  4717. _________________________________________________________________
  4718.  
  4719. *value
  4720. _________________________________________________________________
  4721.  
  4722. Syntax
  4723.  
  4724.    *value(string1)
  4725.  
  4726. Description
  4727.  
  4728.   This rarely-used  function converts  a string  expression to  a
  4729. number.   Its argument  is a  string expression.   This  is fully
  4730. evaluated as  a string,  and then  parsed as a numeric expression
  4731. (as defined  in appendix  B).   This function  returns a  number.
  4732. Parsing errors are reported.
  4733.  
  4734. Example
  4735.  
  4736.    #n = *value("2 + 2")
  4737.  
  4738. This line evaluates the string 2 + 2 as a numeric expression, and
  4739. sets #n to the resulting value.
  4740.  
  4741.  
  4742. _________________________________________________________________
  4743.  
  4744. *volume                (Not supported in SmallRAP)
  4745. _________________________________________________________________
  4746.  
  4747. Syntax
  4748.  
  4749.    *volume(drive)
  4750.  
  4751. Description
  4752.  
  4753.   This function reports the volume label for the specified drive.
  4754. Its argument  is a  string, of  which only the first character is
  4755. used.   If that  character is  a period,  the  current  drive  is
  4756. assumed.   This function  returns a  string,  with  any  trailing
  4757. blanks removed.   For  an invalid  or unlabeled drive, it returns
  4758. Bad-drive or No-label.
  4759.  
  4760. Example
  4761.  
  4762.    $disklabel=*volume($drive) 
  4763.    if $disklabel == "No-label"     
  4764.      t:The disk in drive $drive is not labelled.  
  4765.    else if $disklabel == "Bad-drive"    
  4766.      t:Drive $drive is a bad drive.     
  4767.    else
  4768.      t:The disk in drive $drive is labelled $disklabel.     
  4769.    end if
  4770.  
  4771. This example  reports what it can find out about the label of the
  4772. disk in the specified drive.
  4773.  
  4774.  
  4775. ____________________
  4776.  
  4777.   1 The other access modes of *open may be used, but they all are
  4778. treated the same as w.
  4779.  
  4780.  
  4781. ----------------------------------------------------------------
  4782.  
  4783. Chapter 16
  4784.  
  4785.  
  4786. ERROR AND WARNING MESSAGES
  4787.  
  4788.   
  4789.   This chapter  lists the  error messages  that RAP  can produce,
  4790. along with some explanation of the circumstances under which they
  4791. appear and  some possible  mistakes to  look for in your program.
  4792. If you  get a  whole collection of error messages when you try to
  4793. run a  program, concentrate  on the  first few in the collection.
  4794. They are  more likely  to be  meaningful than the later ones; the
  4795. original problem  may confuse  RAP into  wrong diagnosis of later
  4796. errors.
  4797.  
  4798.   Also bear  in mind that the point where RAP discovers a problem
  4799. is not necessarily the point where your mistake is.  For example,
  4800. if you  leave out an if statement at point A in your program, but
  4801. still include  the end if at point B thirty lines later, RAP will
  4802. not know  there is  a problem until it reaches point B.  Up until
  4803. the unmatched  end if, the  program is  syntactically correct and
  4804. RAP has no reason to think anything is wrong.
  4805.  
  4806.   Even when  RAP reaches the unmatched end if, there is no way to
  4807. know (1)  whether the problem is a missing if or an extra end if,
  4808. or (2)  in the case of a missing if, where you intended it to be.
  4809. The best  RAP can  do is  to report an "unexpected end if" at the
  4810. line where  it was  encountered, and  suggest a "possible missing
  4811. if" as the cause.  This is just what RAP does.
  4812.  
  4813.   Sometimes the  best way  to isolate  an error  is to  cut  your
  4814. program into  smaller pieces  (cut so  that each piece is a valid
  4815. program, even  if it  doesn't do a complete useful task), and see
  4816. which pieces still give problems.
  4817.  
  4818.   One error  condition that  is hard  to track  down because  its
  4819. symptoms are  so variable  is the  unintended continuation.   RAP
  4820. treats any line that ends in a plus sign (+) as a continued line,
  4821. and appends  the following  line to  it.   If the  first line  is
  4822. something like a t or xs statement, the ill-effects won't be seen
  4823. there until run time.  If the second line is something like an if
  4824. statement, its  effective removal will cause trouble at load time
  4825. when an  else or  else if  for that statment is encountered.  The
  4826. source of  the trouble  won't be  obvious, since  you'll still be
  4827. able to see the second statement there in your program file.  The
  4828. real problem,  the "+" that triggers the continuation, is easy to
  4829. overlook. 
  4830.  
  4831.  
  4832. _________________________________________________________________
  4833. A number was expected... please try again.
  4834. A number less than 2147483640 was expected...
  4835.  please try again.
  4836. _________________________________________________________________
  4837.  
  4838.   RAP wants  to input  a number  (because of an a or ah statement
  4839. with a  numeric variable  as its  argument).    Either  of  these
  4840. messages means  that RAP  can't recognize  what you've typed as a
  4841. number.   Remember that  RAP only deals in whole numbers, between
  4842. -2147483640 and 2147483640, with no decimal point.
  4843.  
  4844.  
  4845. _________________________________________________________________
  4846. Arg (argnum) doesn't match parameter
  4847. _________________________________________________________________
  4848.  
  4849.   Some parameter  in a  procedure  or  function  statement  is  a
  4850. numeric variable  name, but  the corresponding  argument  in  the
  4851. calling statement  is not a numeric expression.  This message can
  4852. also result  if one  of the  entries in the parameter list in the
  4853. procedure or function statement is not a variable name.
  4854.  
  4855.   In calling  a procedure  or function,  RAP assigns the value of
  4856. the first  argument  to  the  first  parameter  variable  in  the
  4857. procedure or function statement, the second to the second, and so
  4858. on.  If the parameter in the procedure or function statement is a
  4859. numeric variable,  the  corresponding  argument  in  the  calling
  4860. statement must be a numeric expression.
  4861.  
  4862.  
  4863. _________________________________________________________________
  4864. Bad *chr arg (number)
  4865. _________________________________________________________________
  4866.  
  4867.   The *chr  function converts  a number  to its  (extended) ASCII
  4868. character equivalent.   Since  the extended  ASCII  set  is  only
  4869. defined from  0 to  255, the  argument to  *chr must be a numeric
  4870. expression whose  value is  between 0  and 255.   Otherwise  this
  4871. message results.
  4872.  
  4873.  
  4874. _________________________________________________________________
  4875. Bad constant name:  <input line>
  4876. _________________________________________________________________
  4877.  
  4878.   In a  .define or  .undefine statement, what follows the .define
  4879. or .undef  keyword must  be the  name of  a constant.   This must
  4880. begin with  a period  followed by  a letter  (followed by  up  to
  4881. nineteen additional letters, numbers, or underscores).  Otherwise
  4882. this message results.
  4883.  
  4884.  
  4885. _________________________________________________________________
  4886. Bad file specified
  4887. _________________________________________________________________
  4888.  
  4889.   This message  means that  RAP requested  a file  operation from
  4890. DOS, and  DOS reported  that the  operation failed  because of  a
  4891. problem in  the specification  of the  file.  Check the file name
  4892. (add a  t statement  to display  it), and  check the file on your
  4893. disk.  It might also be worthwhile to check your $path, PATH, and
  4894. COMSPEC settings.
  4895.  
  4896.  
  4897. _________________________________________________________________
  4898. Bad numeric expr in assignment
  4899. _________________________________________________________________
  4900.  
  4901.   In an  assignment statement  where the  variable being  given a
  4902. value is  a numeric  one, the  material on  the right side of the
  4903. equals (or  other assignment  operator) must  be a  valid numeric
  4904. expression.   If not,  this message results.  Usually there is an
  4905. additional message describing what is wrong with the expression.
  4906.  
  4907.  
  4908. _________________________________________________________________
  4909. Bad or missing argument in <built-in function name>
  4910. _________________________________________________________________
  4911.  
  4912.   The built-in  functions each  have specific  requirements about
  4913. the kinds  of arguments they take; these are described in chapter
  4914. 15.   This message  means that  there were  too few  or too  many
  4915. arguments in  the calling statement, or that some argument was of
  4916. the wrong type.
  4917.  
  4918.  
  4919. _________________________________________________________________
  4920. Bad or missing argument in assignment
  4921. _________________________________________________________________
  4922.  
  4923.   The first  thing in an assignment statement must be the name of
  4924. a variable.   This  message means that the statement seemed to be
  4925. an assignment  statement, but  then didn't  start with a variable
  4926. name.   Check for  inadvertent use  of the  c or cs keyword, or a
  4927. colon that doesn't belong at the beginning of the line.
  4928.  
  4929.  
  4930. _________________________________________________________________
  4931. Bad or missing argument in declare
  4932. _________________________________________________________________
  4933.  
  4934.   The argument  in a  declare  statement  must  be  one  or  more
  4935. variable names  separated by  commas.    Otherwise  this  message
  4936. results.   Things to  look for  are an  extra  or  missing  comma
  4937. between names,  a comma  before the  first name or after the last
  4938. one, or a badly-formed variable name.
  4939.  
  4940.  
  4941. _________________________________________________________________
  4942. Bad or missing argument in exit/repeat if
  4943. _________________________________________________________________
  4944.  
  4945.   In an  exit if or repeat if statement, what follows the if must
  4946. be a  numeric expression  to be  evaluated as a test.  If this is
  4947. missing or  badly formed, or if something extra is present before
  4948. it, this  message results.   For a badly formed expression, there
  4949. is usually another error message identifying the problem.
  4950.  
  4951.  
  4952. _________________________________________________________________
  4953. Bad or missing argument in file operation (descriptor)
  4954. _________________________________________________________________
  4955.  
  4956.   A number  of file operations (close, read, rewind, seek, *tell,
  4957. and write)  expect as  their first  argument a numeric expression
  4958. representing the  file descriptor  that was assigned by the *open
  4959. function when  opening this file.  This message means either that
  4960. the numeric  expression was  missing or badly formed, or that its
  4961. value was not the number of a currently open file.
  4962.  
  4963.  
  4964. _________________________________________________________________
  4965. Bad or missing argument in if/elseif
  4966. _________________________________________________________________
  4967.  
  4968.   In an if or else if statement, what follows the command keyword
  4969. must be a numeric expression to be evaluated.  If this is missing
  4970. or badly  formed or  something extra  is present  before it, this
  4971. message results.  For a badly formed expression, there is usually
  4972. another error message identifying the problem.
  4973.  
  4974.  
  4975. _________________________________________________________________
  4976. Bad or missing argument in loop <numexp> times
  4977. _________________________________________________________________
  4978.  
  4979.   The loop  statement has three basic forms:  loop, loop for, and
  4980. loop n  times (where  n is  any valid  numeric expression).    If
  4981. anything other  than the  word for  follows the  word  loop,  RAP
  4982. assumes you  intend the  third form.  It checks that the material
  4983. after loop  consists of  a valid  numeric expression and the word
  4984. times.  This message means that the check failed.
  4985.  
  4986.   If you  did intend  a statement of the loop n times form, check
  4987. that the  numeric expression  is  good  and  the  word  times  is
  4988. present.   If you  didn't intend  loop n times, you have probably
  4989. included something extra after the loop keyword.
  4990.  
  4991.  
  4992. _________________________________________________________________
  4993. Bad or missing argument in loop for
  4994. _________________________________________________________________
  4995.  
  4996.   The loop for statement has two forms: loop for #n = a to b, and
  4997. loop for #n = a to b step c.   In either  case,  #n  may  be  any
  4998. numeric variable,  and a, b, and c are numeric expressions.  This
  4999. error message  means that  something was  wrong with  either  the
  5000. numeric variable,  one  of  the  three  terms,  or  the  keywords
  5001. separating them.  Check for missing or extraneous material.
  5002.  
  5003.  
  5004. _________________________________________________________________
  5005. Bad or missing argument in *open
  5006. _________________________________________________________________
  5007.  
  5008.   The first argument to the *open function is a string containing
  5009. a filename.   This message means either that no filename argument
  5010. was provided, or that one was provided which was not a string.
  5011.  
  5012.  
  5013. _________________________________________________________________
  5014. Bad or missing argument in *open (bad mode)
  5015. _________________________________________________________________
  5016.  
  5017.   The optional  second argument  to *open  is a string specifying
  5018. the access mode in which the file is to be opened.  Its value may
  5019. be r,  w, or  a, x, r+, w+, a+, or x+.  This message means that a
  5020. mode argument was provided which was not one of these.
  5021.  
  5022.  
  5023. _________________________________________________________________
  5024. Bad or missing argument in option accept
  5025. _________________________________________________________________
  5026.  
  5027.   In an  option statement  in a menu, the accept keyword lets you
  5028. specify the responses that will be accepted for this option.  The
  5029. accept keyword  should be  followed by a left parenthesis, then a
  5030. list of  response  patterns  (string  expressions)  separated  by
  5031. commas,  then   a  right  parenthesis.    Recall  that  a  string
  5032. expression may be a string variable name, a string function name,
  5033. or a  quoted string.   This  message means  that something is not
  5034. right.
  5035.  
  5036.  
  5037. _________________________________________________________________
  5038. Bad or missing argument in option if
  5039. _________________________________________________________________
  5040.  
  5041.   In an if or else if statement, what follows the command keyword
  5042. must be a numeric expression to be evaluated.  If this expression
  5043. is missing  or badly  formed, or  if something  extra is  present
  5044. before it,  this message results.  For a badly formed expression,
  5045. there is usually another error message identifying the problem.
  5046.  
  5047.  
  5048. _________________________________________________________________
  5049. Bad or missing argument in parentheses
  5050. _________________________________________________________________
  5051.  
  5052.   RAP is  attempting to parse a numeric expression, and has found
  5053. something illegal within parentheses.
  5054.  
  5055.  
  5056. _________________________________________________________________
  5057. Bad or missing argument in poke
  5058. _________________________________________________________________
  5059.  
  5060.   The (not-recommended)  poke command expects two arguments, both
  5061. numeric expressions,  separated by  a comma.   This message means
  5062. that it found something different.
  5063.  
  5064.  
  5065. _________________________________________________________________
  5066. Bad or missing argument in proc/function call
  5067. _________________________________________________________________
  5068.  
  5069.   The arguments  in a  procedure or function call must be numeric
  5070. expressions or  string expressions,  separated by  commas.   This
  5071. message means  that something  was encountered that was neither a
  5072. numeric expression  nor a  string one.    Recall  that  a  string
  5073. expression may be a string variable name, a string function call,
  5074. or a quoted string.  Check all your arguments, and check also for
  5075. missing or extra commas.
  5076.  
  5077.  
  5078. _________________________________________________________________
  5079. Bad or missing argument in read (string var)
  5080. _________________________________________________________________
  5081.  
  5082.   The second  argument in  a read  statement is a string variable
  5083. indicating where  the value  read is  to be  stored. This message
  5084. means that  RAP found  no  second  argument,  or  that  it  found
  5085. something there which was not a string variable name.
  5086.  
  5087.  
  5088. _________________________________________________________________
  5089. Bad or missing argument in seek
  5090. _________________________________________________________________
  5091.  
  5092.   The seek  command takes  as its  arguments a numeric expression
  5093. (usually just  a numeric  variable) identifying the number of the
  5094. file  where   the  seek   is  to   occur,  a  numeric  expression
  5095. representing the distance to seek, and an optional third argument
  5096. that is either the word bytes or relbytes.  The arguments must be
  5097. separated by  commas.   This message means that the statement did
  5098. not follow these rules.
  5099.  
  5100.  
  5101. _________________________________________________________________
  5102. Bad or missing argument in *tell
  5103. _________________________________________________________________
  5104.  
  5105.   The *tell  function must  have exactly one argument, which must
  5106. be a numeric expression (and is usually a numeric variable).  Its
  5107. value is  the descriptor  of  the  file  for  which  the  pointer
  5108. position is wanted.  Anything different gives this message.
  5109.  
  5110.  
  5111. _________________________________________________________________
  5112. Bad or missing argument in vrestore or vsave
  5113. _________________________________________________________________
  5114.  
  5115.   No filename was provided in a vsave or vrestore command.
  5116.  
  5117.  
  5118. _________________________________________________________________
  5119. Bad or missing argument in xcall/xchain (file not found)
  5120. _________________________________________________________________
  5121.  
  5122.   This message  can mean  one of  two things:  either no filename
  5123. was provided  in an  xcall or  xchain statement, or the file that
  5124. was named  in that  statement could  not be  found on  the  disk.
  5125. Check that:   (1) the name that you're providing really is right,
  5126. (2) it's  an executable  .EXE or  .COM file (you need xs to run a
  5127. .BAT batch file), (3) the file really is on the disk, and (4) the
  5128. directory it's  in is  either the  current directory or is on the
  5129. $path list.
  5130.  
  5131.  
  5132. _________________________________________________________________
  5133. Bad or missing name in proc/function statement
  5134. _________________________________________________________________
  5135.  
  5136.   In  a   procedure  or  function  statement,  the  name  of  the
  5137. subprogram must  follow the  procedure or function keyword.  This
  5138. message means  that RAP did not find it there.  This could be due
  5139. to a  missing name,  a  badly  formed  one,  or  something  extra
  5140. inserted before the name.
  5141.  
  5142.  
  5143. _________________________________________________________________
  5144. Bad or missing simple factor
  5145. _________________________________________________________________
  5146.  
  5147.   RAP was  parsing a numeric expression, and was at a point where
  5148. it required  either a  number,  a  numeric  variable,  a  numeric
  5149. function call,  or a  parenthesized numeric expression (or any of
  5150. these preceded  by a +, , or not operator).  It found none of the
  5151. above.   Check for extra or missing arithmetic operators, missing
  5152. pound signs  on numeric  variables, missing asterisks on function
  5153. calls,  mismatched   parentheses,  and  so  on.    If  a  numeric
  5154. expression is too complicated to check easily, you might split it
  5155. up and do the calculation in several statements.
  5156.  
  5157.  
  5158. _________________________________________________________________
  5159. Bad pattern
  5160. _________________________________________________________________
  5161.  
  5162.   There's something  wrong with the pattern in a pattern matching
  5163. operation using  has or  contains, or in an option accept clause.
  5164. Some things  that the match facility will balk at include ^*, $*,
  5165. **, and extremely long patterns.
  5166.  
  5167.  
  5168. _________________________________________________________________
  5169. Bad string comparison
  5170. _________________________________________________________________
  5171.  
  5172.   RAP was  parsing a  numeric expression, and in the process came
  5173. across something that looked like a string comparison.  RAP found
  5174. the first  string expression  (quoted string, string variable, or
  5175. string function  call) and  the  comparison  operator,  but  what
  5176. followed  the   comparison  operator   was  not   another  string
  5177. expression.   One possible  cause for  this error is the use of a
  5178. string function  where you intended to use a numeric function, or
  5179. vice-versa.  Other possible causes include extra or missing items
  5180. on the line.
  5181.  
  5182.  
  5183. _________________________________________________________________
  5184. Bad subscript
  5185. _________________________________________________________________
  5186.  
  5187.   A subscript,  if used,  must come  immediately after a variable
  5188. name.     It  consists  of  a  left  square  bracket,  a  numeric
  5189. expression, and a right square bracket.  If what follows the left
  5190. square bracket is not a valid numeric expression, or if its value
  5191. is not  between 0  and 999,  or if  there is  not a  right square
  5192. bracket following it, this message results.
  5193.  
  5194.   If you want a left square bracket as part of the text following
  5195. a variable  name in  a string,  and you  don't intend  it as  the
  5196. beginning marker  of a  subscript, you  can separate  the bracket
  5197. from the name by putting a single backslash between them.
  5198.  
  5199.  
  5200. _________________________________________________________________
  5201. Division, rem, or mod by 0
  5202. _________________________________________________________________
  5203.  
  5204.   RAP attempted  to evaluate  a numeric  expression  involving  a
  5205. division by  zero, or  a rem  or mod  operation with  zero as the
  5206. second operand.   One  mistake that  can lead to this error is to
  5207. divide by  a variable  which you  have declared but never given a
  5208. value.
  5209.  
  5210.  
  5211. _________________________________________________________________
  5212. DOS error <DOSerrnum>
  5213. _________________________________________________________________
  5214.  
  5215.   RAP attempted  to do  some operation  that required  the use of
  5216. DOS, and  DOS reported  an error.   For  many  such  errors,  RAP
  5217. recognizes the  error code returned by DOS, and interprets it for
  5218. you, as  for example,  "insufficient memory"  or "invalid  seek."
  5219. This message  is used  for the  less-common DOS  error codes  not
  5220. known to RAP.
  5221.  
  5222.  
  5223. _________________________________________________________________
  5224. Expanded string too long... truncated.
  5225. _________________________________________________________________
  5226.  
  5227.   This message  means that  a string  evaluation  step  tried  to
  5228. produce a string that was longer than 255 characters, the maximum
  5229. length allowed.  The string produced was cut off at 255.
  5230.  
  5231.  
  5232. _________________________________________________________________
  5233. Extra text in line
  5234. _________________________________________________________________
  5235.  
  5236.   This message  can appear in many different contexts; in general
  5237. it means  that there  is something  more on  the line (other than
  5238. valid comments)  after the allowed arguments.  One possible cause
  5239. is badly  formed comments;  remember that same-line comments must
  5240. begin with a semicolon after one or more tabs or spaces.  Another
  5241. possible cause  is a  line like if #n = 4, which incorrectly uses
  5242. the single-equals assignment operator where what was intended was
  5243. the double-equals equality comparison operator of if #n == 4. RAP
  5244. correctly sees  the first  part, if #n, as a valid statement, and
  5245. wonders what the part beginning with the single = is there for.
  5246.  
  5247.  
  5248. _________________________________________________________________
  5249. File is read-only
  5250. _________________________________________________________________
  5251.  
  5252.   You attempted to modify a file that is marked (by DOS) as read-
  5253. only.   Specify a  different file, or use the DOS copy command to
  5254. make a  writable copy  of the  file you're  interested in (with a
  5255. different name), or alter the file attributes to allow writing.
  5256.  
  5257.  
  5258. _________________________________________________________________
  5259. File not found
  5260. _________________________________________________________________
  5261.  
  5262.   RAP could  not find  the file  you  referred  to.    Check  the
  5263. spelling of  the filename  and extensions, and make sure that the
  5264. file is  in the current directory or in one of the subdirectories
  5265. named in the current $path.
  5266.  
  5267.  
  5268. _________________________________________________________________
  5269. INCLUDEs nested too deeply
  5270. _________________________________________________________________
  5271.  
  5272.   Your main  program may  include another  file by  means of  the
  5273. .include keyword,  and that file may include another, for a total
  5274. of three  levels.   If you  try to  .include down  to four levels
  5275. deep,  this  message  results.    Reorganizing  your  program  is
  5276. probably in order; it shouldn't be necessary to go that deep.
  5277.  
  5278.  
  5279. _________________________________________________________________
  5280. Insufficient memory for xcall/xchain
  5281. _________________________________________________________________
  5282.  
  5283.   RAP tried  to do  an xcall  or xchain, but there was not enough
  5284. memory to  hold RAP  and the other program at the same time.  Due
  5285. to bugs  in the  C compiler  we use, xchain in version 1.0 of RAP
  5286. just does  an xcall  and a  bye, so  it still  has to have enough
  5287. memory present  for both  RAP and the program you're chaining to.
  5288. See the "Out of memory..." message description for suggestions on
  5289. conservation.
  5290.  
  5291.  
  5292. _________________________________________________________________
  5293. Insufficient memory for DOS command
  5294. _________________________________________________________________
  5295.  
  5296.   RAP tried  to do  some DOS  command such  as required  for dir,
  5297. edit, list,  or xs,  and there  was not  enough memory to do that
  5298. function with RAP loaded too.  See the "Out of memory..." message
  5299. description for suggestions on conservation.
  5300.  
  5301.  
  5302. _________________________________________________________________
  5303. Invalid command
  5304. _________________________________________________________________
  5305.  
  5306.   This usually  means that  the immediate  command you have typed
  5307. doesn't begin  with any  keyword that RAP can recognize, nor does
  5308. it begin  with a  variable name  or a known procedure name.  This
  5309. could indicate  a misspelled  command  keyword,  a  badly  formed
  5310. variable or  procedure name,  a misspelled  procedure name,  or a
  5311. reference to  a procedure  that you inadvertently left out of the
  5312. program.  This message may also mean that you have used a command
  5313. in immediate mode which may not be used there.
  5314.  
  5315.  
  5316. _________________________________________________________________
  5317. Invalid exit/repeat
  5318. _________________________________________________________________
  5319.  
  5320.   This message may mean that an exit or repeat statement was used
  5321. outside of  any loop  or menu,  or it  may mean that an exit n or
  5322. repeat n statement  was used  where the  number n  was  negative,
  5323. zero, or greater than the number of enclosing loops and/or menus.
  5324.  
  5325.  
  5326. _________________________________________________________________
  5327. Invalid seek
  5328. _________________________________________________________________
  5329.  
  5330.   This message  means  that  something  was  wrong  with  a  seek
  5331. attempt.   The most  likely problem  is an offset which would put
  5332. the file pointer before the beginning of the file.
  5333.  
  5334.  
  5335. _________________________________________________________________
  5336. Invalid xi
  5337. _________________________________________________________________
  5338.  
  5339.   The xi  statement evaluates  its argument  as a  RAP  statement
  5340. (including a command keyword), and executes it.  Certain commands
  5341. are not  allowed as the command keyword in that argument, notably
  5342. xi itself.
  5343.  
  5344.  
  5345. _________________________________________________________________
  5346. Missing '(' in paramlist.
  5347. _________________________________________________________________
  5348.  
  5349.   A procedure  or function statement may end with the name of the
  5350. procedure/function, or  it may have a list of parameter variables
  5351. after the  name.   Such a  list is contained in parentheses, with
  5352. commas between  the variable  names.   This  message  means  that
  5353. something was  found after  the procedure/function  name that was
  5354. not a  left parenthesis.   Either  there's something  missing  or
  5355. something extra.
  5356.  
  5357.  
  5358. _________________________________________________________________
  5359. Missing ')' in paramlist
  5360. _________________________________________________________________
  5361.  
  5362.   If a  procedure or  function statement  does  have  a  list  of
  5363. parameter variables, that list must end with a right parenthesis.
  5364. This message means that something was found after a variable name
  5365. that was  neither a  comma (indicating  that another  name should
  5366. follow) nor a right parenthesis (indicating the end of the list).
  5367. Check for something missing or something extra.
  5368.  
  5369.  
  5370. _________________________________________________________________
  5371. Missing <item> in vrestore file
  5372. _________________________________________________________________
  5373.  
  5374.   The vrestore  command is reading from a file and is not finding
  5375. what should  be there.   If  the file  being read is one that RAP
  5376. wrote with  a vsave  command, then  this is  a RAP internal error
  5377. that we'd like to hear about.  If it is one that you have edited,
  5378. you're on  unsupported ground.   Make  sure you match the current
  5379. format of  vsave files, and good luck.  We don't encourage use of
  5380. vsave and vrestore, much less the hacking thereof.
  5381.  
  5382.  
  5383. _________________________________________________________________
  5384. Missing = in assignment
  5385. Missing = or assignment operator
  5386. _________________________________________________________________
  5387.  
  5388.   RAP  encountered  something  that  looked  like  an  assignment
  5389. statement but  had no  equals sign (or other assignment operator)
  5390. after the variable name.  RAP will recognize as an assignment any
  5391. statement that  (1) begins  with a variable name, (2) begins with
  5392. the keyword  c, or  (3) begins  with a  colon where  the previous
  5393. statement was  an assignment.  If you did intend the statement to
  5394. be an  assignment, the  problem could be a missing equals sign, a
  5395. badly formed  variable name,  or some extra garbage between them.
  5396. If an  assignment statement  was not what you intended, then make
  5397. sure that none of the three conditions listed is true.
  5398.  
  5399.  
  5400. _________________________________________________________________
  5401. Missing close quote
  5402. _________________________________________________________________
  5403.  
  5404.   RAP is  in the midst of some circumstance that expects a quoted
  5405. string.   The opening  quotes were  there, but no closing quotes.
  5406. This  could   be  a  symptom  of  a  too-long  string.    Another
  5407. possibility happens  if the  string ends  with a backslash before
  5408. the closing  quotes.   This will  cause the  closing quotes to be
  5409. taken as part of the string, instead of as an ending mark, and no
  5410. ending mark  will be  found.   Doubling the  backslash may be the
  5411. answer in this case.
  5412.  
  5413.  
  5414. _________________________________________________________________
  5415. Name too long: <name>
  5416. _________________________________________________________________
  5417.  
  5418.   The name  of the  indicated variable,  constant,  function,  or
  5419. procedure is  too long.   A  name can consist of a special symbol
  5420. (#,*,$, or  .) followed by a letter and up to nineteen additional
  5421. letters, digits,  and underscores.   Anything  longer produces an
  5422. error message.   If in some line of a program you have a variable
  5423. name  followed  by  a  series  of  other  letters,  numbers,  and
  5424. underscores, RAP will assume that the whole thing constitutes one
  5425. long variable  name which may violate the above limit.  You might
  5426. in this  case separate  the  variable  name  from  the  following
  5427. context by means of a backslash.
  5428.  
  5429.  
  5430. _________________________________________________________________
  5431. No main procedure
  5432. _________________________________________________________________
  5433.  
  5434.   If  your   program  is  entirely  composed  of  procedures  and
  5435. functions with  no loose  code,  one  of  the  procedures  (which
  5436. presumably calls  the others)  must be  named main  to serve as a
  5437. starting point.   This  message means  that no  main procedure is
  5438. present, so RAP does not know where to start.
  5439.  
  5440.  
  5441. _________________________________________________________________
  5442. Not enough args in proc/function call
  5443. _________________________________________________________________
  5444.  
  5445.   In a  call to  a procedure or function, the number of arguments
  5446. in the  calling statement  must match the number of parameters in
  5447. the procedure  or function  statement.   This message  says  they
  5448. don't match.
  5449.  
  5450.  
  5451. _________________________________________________________________
  5452. Number too big:  limit is 2147483640
  5453. _________________________________________________________________
  5454.  
  5455.   Numbers in  RAP can  be between -2147483640 and 2147483640.  If
  5456. you try to assign a numeric value that is out of this range, this
  5457. message results.   (Surely  two billion  of anything  has  to  be
  5458. enough.)
  5459.  
  5460.  
  5461. _________________________________________________________________
  5462. Out of memory in <some obscure description>
  5463. _________________________________________________________________
  5464.  
  5465.   There is  not enough  memory to  run the  current RAP  program.
  5466. Various forms  of this  message can  come up  during  loading  or
  5467. during execution.   Memory  is used  for storing the RAP program,
  5468. any variables  that it  uses, and internal stacks and tables used
  5469. by the interpreter in keeping track of what it's doing.
  5470.  
  5471.   If you're  running out  of memory  due  to  a  very  large  RAP
  5472. program, you  might consider  breaking it  into smaller pieces or
  5473. using LargeRAP.   If your program doesn't look like it should use
  5474. that much  memory, one thing to check for is excessive recursion.
  5475. That's where  a function  or procedure  calls itself,  which then
  5476. calls itself, and so on to many levels.  RAP has to keep track of
  5477. a lot  of information  for each  level, so that if there are many
  5478. levels RAP may run out of memory trying to store it all.
  5479.  
  5480.   Other ways  to deal  with out-of-memory  errors are to decrease
  5481. the size  of any  RAM disks  or other  resident programs  you are
  5482. using, or to use SmallRAP.
  5483.  
  5484.  
  5485. _________________________________________________________________
  5486. Possible missing <command>
  5487. _________________________________________________________________
  5488.  
  5489.   This message  appears together with an "unexpected <something>"
  5490. message.   It is  an educated guess, usually telling you what was
  5491. expected instead  of the  <something>.   Take it  as a suggestion
  5492. rather than  an authoritative diagnosis.  Sometimes this provides
  5493. a good  hint about what might be wrong earlier in your program to
  5494. give RAP different expectations.
  5495.  
  5496.  
  5497. _________________________________________________________________
  5498. Prefixed string too long... truncated.
  5499. _________________________________________________________________
  5500.  
  5501.   This is a rare message.  At loading time, it means that a call,
  5502. a loop while, or an until statement was too long.  RAP statements
  5503. can normally  be up  to 255  characters  long,  but  these  three
  5504. statements have  some material  added at  the  beginning  by  the
  5505. loader, so  their limits  are slightly less.  They can all handle
  5506. at least 240 characters.
  5507.  
  5508.   At run  time, this  message can  appear if  the text  on a menu
  5509. option is too long, and RAP cannot prepend the letter tag for the
  5510. option.
  5511.  
  5512.  
  5513. _________________________________________________________________
  5514. Proc/function name too long: <name>
  5515. _________________________________________________________________
  5516.  
  5517.   The name  of the  indicated procedure  or function is too long.
  5518. See  section   12.2,  and  the  "name  too  long"  error  message
  5519. explanation.
  5520.  
  5521.  
  5522. _________________________________________________________________
  5523. Program file <filename> not found
  5524. _________________________________________________________________
  5525.  
  5526.   A RAP  program file mentioned in a load, run, or .include could
  5527. not be  found.   Check that  the file is on the disk, the name is
  5528. correct in  the program,  and the  $path (or  DOS PATH) lists the
  5529. desired directory if the file is not in the current directory.
  5530.  
  5531.  
  5532. _________________________________________________________________
  5533. Quoted string too long
  5534. _________________________________________________________________
  5535.  
  5536.   This message  means that some string in quotes is more than 255
  5537. characters long.  Since the statement the string appears in can't
  5538. be over  255 characters  long, this  message should  never occur.
  5539. Send us a postcard if it does.
  5540.  
  5541.  
  5542. _________________________________________________________________
  5543. RAP internal error - <some obscure text or number>
  5544. _________________________________________________________________
  5545.  
  5546.   This means  that RAP  has detected  something that  it's  doing
  5547. wrong ...  whatever's happening  may not be your fault.  Messages
  5548. like this  shouldn't appear  no matter  what  you  do  with  your
  5549. program;[1] if they do they reflect bugs in RAP that we would like
  5550. to know  about and  fix.   If you can write down the message, and
  5551. send us  a disk  with a  copy of the program that produced such a
  5552. message and instructions on how to get it to that point again (if
  5553. it seems  to be repeatable), we will be most grateful.  Send your
  5554. report to the address on the back of the title page.
  5555.  
  5556.  
  5557. _________________________________________________________________
  5558. Redefined name <constant-name> (ignored)
  5559. _________________________________________________________________
  5560.  
  5561.   This message  means that the loader found more than one .define
  5562. statement defining  the same  constant  name.    Only  the  first
  5563. definition is  used; the second one is ignored, which is probably
  5564. bad news.
  5565.  
  5566.  
  5567. _________________________________________________________________
  5568. Sorry... there's no help info on this question.
  5569. _________________________________________________________________
  5570.  
  5571.   If a  menu does  not include  a help-group, typing "help" gives
  5572. you this message.  It means what it says.
  5573.  
  5574.  
  5575. _________________________________________________________________
  5576. String too long - truncated <string>
  5577. _________________________________________________________________
  5578.  
  5579.   If expanding  variable names  and function  calls in  a  string
  5580. forces it  to exceed  255 characters  in length, everything after
  5581. the 255th  character is  discarded and  this warning appears.  If
  5582. you weren't  expecting a  long string, add a t or ts statement to
  5583. see what  it contains.   Sometimes  a string variable or function
  5584. that contains itself embedded within itself can get out of hand.
  5585.  
  5586.  
  5587. _________________________________________________________________
  5588. Too many args in proc/function call
  5589. _________________________________________________________________
  5590.  
  5591.   In a  call to  a procedure or function, the number of arguments
  5592. in the  calling statement  must match the number of parameters in
  5593. the procedure  or function  statement.   This message  says  they
  5594. don't match.
  5595.  
  5596.  
  5597. _________________________________________________________________
  5598. Too many user files are open
  5599. _________________________________________________________________
  5600.  
  5601.   RAP only  allows a  limited number of files to be open at once:
  5602. four in  SmallRAP, eight  in RAP  and LargeRAP.   You may need to
  5603. close some files to open others.
  5604.  
  5605.  
  5606. _________________________________________________________________
  5607. Unable to do DOS command - command.com might not be on boot disk
  5608. _________________________________________________________________
  5609.  
  5610.   RAP failed at some DOS command, such as required for dir, edit,
  5611. list, and  xs, and  the cause  was probably not a lack of memory.
  5612. This is a general-purpose message, but the most frequent cause is
  5613. the one  mentioned in the message.  Make sure that COMMAND.COM is
  5614. accessible on  some drive and that the DOS COMSPEC variable tells
  5615. exactly where to find it.
  5616.  
  5617.   If finding  COMMAND.COM isn't  the problem,  make sure that the
  5618. syntax of your dir argument, edit or list filename, or xs command
  5619. is right.  Use a t statement to find out what is in the argument,
  5620. filename, or  command, then  exit to  DOS and see what happens if
  5621. you try to ask DOS to do what RAP couldn't get it to do.
  5622.  
  5623.  
  5624. _________________________________________________________________
  5625. Unable to open file (<filename>)
  5626. _________________________________________________________________
  5627.  
  5628.   RAP tried  to open  the specified  file but  was unable.   This
  5629. could be  because the  name  is  badly  formed,  or  because  you
  5630. attempted to  open a  read-only file for writing or a nonexistent
  5631. file for  reading, or because you are trying to create a new file
  5632. on a  completely full  disk, or  because you  have reached  DOS's
  5633. limit on the number of open files.  DOS's limit is different from
  5634. RAP's, and  is set  by the  FILES= statement  in a DOS CONFIG.SYS
  5635. file.  See your DOS manual for more on this topic.
  5636.  
  5637.  
  5638. _________________________________________________________________
  5639. Unable to read file
  5640. _________________________________________________________________
  5641.  
  5642.   This message  appears when  an error  occurs  while  reading  a
  5643. program file.   You may want to look through the file with a text
  5644. editor, to  run the  DOS chkdsk  command on that disk, or to copy
  5645. the file to another disk.
  5646.  
  5647.  
  5648. _________________________________________________________________
  5649. Unable to run with the errors described
  5650. _________________________________________________________________
  5651.  
  5652.   This message  means that  errors occurred during loading of the
  5653. program, with  the result  that RAP is unable to run the program.
  5654. The errors  should have  been reported  as they  were encountered
  5655. during loading.  Edit the program file to fix them and try again.
  5656.  
  5657.  
  5658. _________________________________________________________________
  5659. Undefined variable (<varname>)
  5660. _________________________________________________________________
  5661.  
  5662.   You have  apparently used  a  numeric  variable  without  first
  5663. assigning it  a value.   Recheck the logic in your program.  Also
  5664. check for  misspelled variable names or use of the wrong variable
  5665. name.
  5666.  
  5667.  
  5668. _________________________________________________________________
  5669. Unexpected <command-name>
  5670. _________________________________________________________________
  5671.  
  5672.   This is a general-purpose message that typically means that the
  5673. statement encountered was not legal at that point in the program.
  5674. An end if where there is no if statement would be a good example,
  5675. or an  end function statement  at the  end  of  a  procedure,  or
  5676. attempting to  begin a  procedure or  function before  ending its
  5677. predecessor.
  5678.  
  5679.   Often this message is the result of a missing statement earlier
  5680. in the  program, or  an extra  statement  inadvertantly  left  in
  5681. somewhere along the line.
  5682.  
  5683.   RAP will  usually accompany  this message with a hint about the
  5684. kind of  statement it  might have  considered more appropriate at
  5685. that point.   If the current statement looks appropriate where it
  5686. is, the  "possible missing  ..." message may help you identify an
  5687. earlier  point   in  your  program  where  some  error  gave  RAP
  5688. unreasonable expectations.
  5689.  
  5690.   Check  that   your  constructs   are  all  properly  formed  in
  5691. accordance with  the examples  (and the  syntax  descriptions  in
  5692. appendix B).  When all else fails, simplify.
  5693.  
  5694.  
  5695. _________________________________________________________________
  5696. Unexpected argument
  5697. _________________________________________________________________
  5698.  
  5699.   Certain commands take no arguments.  These include ce, cl, cls,
  5700. debug, endfunction,  endif, endloop,  endproc, and  then.    This
  5701. message means  that something  appeared on  the line after one of
  5702. these keywords, where nothing belongs.
  5703.  
  5704.  
  5705. _________________________________________________________________
  5706. Unexpected string found
  5707. Unexpected string or bad string comparison
  5708. _________________________________________________________________
  5709.  
  5710.   This message,  in either  form, identifies a syntax error in an
  5711. expression.   RAP was parsing a numeric expression, looking for a
  5712. factor, and  came across  a string  expression (either  a  quoted
  5713. string, a  string function,  or a  string variable).   So  far so
  5714. good: in  the context  of a  factor, a string is allowed if it is
  5715. the first  term in  a string comparison.  This message means that
  5716. what follows the string is not a comparison operator, so we don't
  5717. have a  string comparison.  RAP doesn't know what to make of what
  5718. it does have, but it knows that it's not legal RAP code.
  5719.  
  5720.   Either the  string expression doesn't belong where it is, or it
  5721. does belong  and a  comparison operator is missing.  One possible
  5722. cause of  this message  is  a  string  function  used  where  you
  5723. intended a numeric one.
  5724.  
  5725.  
  5726. _________________________________________________________________
  5727. Unknown command
  5728. _________________________________________________________________
  5729.  
  5730.   On loading  a program, RAP has found a line that does not begin
  5731. with a valid command keyword, a variable name (in an assignment),
  5732. a procedure name (in a call), or a colon (with a valid repeatable
  5733. command on  the  previous  line).    Those  are  the  only  legal
  5734. possibilities.  Check the spelling, if you have a command keyword
  5735. on the  line.  If it's an assignment, make sure you have the # or
  5736. $ on  the beginning  of the  variable name.   If it's a procedure
  5737. call, make  sure that  the procedure you're calling is present in
  5738. your program and that the name is spelled consistently.
  5739.  
  5740.  
  5741. _________________________________________________________________
  5742. Unknown proc/function name <name>
  5743. _________________________________________________________________
  5744.  
  5745.   In a call statement, this message means that RAP could not find
  5746. the procedure  requested.  This is usually due to spelling errors
  5747. or to omission of include-files.
  5748.  
  5749.   Where a  function call  is  embedded  in  an  expression,  this
  5750. message means  that RAP  could not  find that function.  The same
  5751. two main  causes apply.  A third possibility is that something in
  5752. the string  looks like  a function call when it isn't.  Watch out
  5753. for asterisks  followed by  letters; if necessary you can prevent
  5754. RAP from  treating something  as a  function call by preceding or
  5755. following the asterisk with a single backslash.
  5756.  
  5757.  
  5758. _________________________________________________________________
  5759. Unreachable statement(s) found after proc/function end
  5760. Unreachable statement(s)
  5761. _________________________________________________________________
  5762.  
  5763.   This message  (in either  form)  means  that  in  loading  your
  5764. program RAP  found one  or more  statements after  the end  of  a
  5765. procedure or function that were not contained in any procedure or
  5766. function.   This could  be between procedures/functions, or after
  5767. the last  one.   Loose code is allowed only before the very first
  5768. procedure or  function.   If you  use include-files,  check to be
  5769. sure that  their contents  may properly go in the place where the
  5770. .include statement is.
  5771.  
  5772.  
  5773. _________________________________________________________________
  5774. Unsuccessful xcall/xchain
  5775. _________________________________________________________________
  5776.  
  5777.   This message  means that  an xcall  or xchain  attempt  failed,
  5778. apparently for  some reason other than lack of memory.  Make sure
  5779. that  the   evaluated  argument  to  the  xcall  or  xchain  does
  5780. constitute a  valid request  to run  an executable (.EXE or .COM)
  5781. program.   You can't xcall or xchain to .RAP files, or .BAT ones,
  5782. or even .BAS programs.
  5783.  
  5784.   Use a  t statement to find out exactly what is in the argument,
  5785. then exit  to DOS  and see  what happens if you try to ask DOS to
  5786. run the program.
  5787.  
  5788. ____________________
  5789.  
  5790.   1 Unless you use poke.
  5791.  
  5792.  
  5793. ----------------------------------------------------------------
  5794.  
  5795.  
  5796. APPENDIXES
  5797.  
  5798.  
  5799.       A. Summary of commands, functions, and variables
  5800.  
  5801.       B. Formal syntax definition
  5802.  
  5803.       C. ANSI screen-control codes
  5804.  
  5805.       D. Input codes for special keys
  5806.  
  5807.       E. Differences between RAP models
  5808.  
  5809.                 
  5810.  
  5811.                 
  5812.  
  5813. A. Summary of commands, functions, and variables
  5814.  
  5815.                                    
  5816.                                Commands
  5817.  
  5818. Items marked with a plus sign (+) are not supported in SmallRAP.
  5819.  
  5820.    a                 input from the keyboard to a variable
  5821. +  ah                like a, but leave cursor at end
  5822.    as                input a single character from the keyboard
  5823.    bye               exit from RAP environment
  5824.    c                 assign a value to numeric or string variable
  5825.    ca                move cursor to a specified line and column
  5826.    call              call a procedure
  5827. +  ce                clear from cursor to end of screen
  5828.    cl                clear from cursor to end of line
  5829.    close             close a file
  5830.    cls               clear entire screen
  5831.    cs                faster form of c, but without evaluation
  5832. +  debug             examine internal code and tables
  5833.    declare           declare local variables
  5834. +  dir               list a directory on the screen
  5835. +  edit              edit a file and reload the program
  5836.    else              default alternative clause for if construct
  5837.    else if           alternative clause for if construct
  5838.    end function      marks end of a numeric or string function
  5839.    end if            end of if construct
  5840.    end loop          end of loop construct... branch back to top
  5841.    end menu          end of menu construct
  5842.    end proc          end of procedure... implies return
  5843.    exit              unconditional branch out of loop or menu
  5844.    exit if           conditional branch out of loop or menu
  5845.    foot              display text at bottom of screen and wait
  5846.    help              start of help group in menu construct
  5847.    if                conditional clause of if construct
  5848.    killf             delete a file
  5849. +  list              list main program file to screen or printer
  5850.    load              read in a program, but do not run it
  5851.    loop              start of loop construct
  5852.    menu              start of menu construct
  5853.    num function      abbreviation for numeric function
  5854.    numeric function  marks beginning of numeric function
  5855.    option            start of option group in menu construct
  5856. +  pause             delay for 1-60 seconds
  5857. +  poke              place a value in memory
  5858.    proc              marks beginning of procedure
  5859.    r                 marks remark (comment)
  5860.    read              read a line from a file to a string variable
  5861.    repeat            branch to top of loop or menu construct
  5862.    return            exit from subprogram, return to caller
  5863.    rewind            point file pointer to top of file
  5864.    run               run the program, or load and run a new one
  5865.    seek              move read/write pointer to place in a file
  5866.    str function      abbreviation for string function
  5867.    string function   marks beginning of string function
  5868.    t                 type (display) line to screen
  5869.    th                type line to screen, leave cursor at end
  5870.    then              follows if statement (not required)
  5871.    ts                faster form of t, but without evaluation
  5872.    tsh               faster form of th, but without evaluation
  5873.    until             end of loop construct with test
  5874. +  vnew              delete variables from symbol table
  5875. +  vrestore          read variables from file to symbol table
  5876. +  vsave             write variables from symbol table to file
  5877.    wr                abbreviation for write
  5878.    write             write a line to a file
  5879.    xcall             call an external program from within RAP
  5880.    xchain            chain to an external program
  5881.    xi                execute a string as a RAP statement
  5882.    xs                execute a string as a DOS command
  5883.  
  5884.  
  5885.                         Built-in functions
  5886.  
  5887. Items marked with a plus sign (+) are not supported in SmallRAP.
  5888.  
  5889.    *ascii(string1)          converts char to ASCII number
  5890.    *chr(num1)               converts number to ASCII char
  5891. +  *currdir()               reports the current directory
  5892. +  *currdriv()              reports the current disk drive
  5893.    *date()                  reports the current date
  5894.    *envir(string1)          gets value of DOS environment variable
  5895.    *escape_symbols(string2) escapes #, *, $, and \ in string
  5896.    *existf(file1,access)    does file1 exist?  is it accessible?
  5897. +  *filesize(file1)         file size in bytes
  5898. +  *filetime(file1)         time and date of a file
  5899. +  *fileymdt(file1)         sortable-form file time and date
  5900.    *final_eval(string1)     text evaluation of string
  5901.    *findpath(file1,access)  reports where a file is found
  5902. +  *freesp(drive)           free space on drive, bytes
  5903.    *index(string1,string2)  locate character in string1
  5904.    *isnumber(string1)       is string1 a number?
  5905. +  *isnumexp(string1)       is string1 a numeric expression?
  5906.    *keypress()              anything in the typeahead buffer?
  5907.    *memfree()               reports available memory
  5908.    *mid(string1,start,len)  takes a substring
  5909.    *open(file1,access)      opens a file
  5910. +  *peek(address)           examines a byte of memory
  5911.    *strlen(string1)         length of a string
  5912.    *tell(descriptor)        position within file
  5913.    *time()                  reports the current time
  5914.    *value(string1)          evaluate string as numeric expr
  5915. +  *volume(drive)           volume label on a disk drive
  5916.  
  5917.  
  5918.                         Built-in variables
  5919.  
  5920. Items marked with a plus sign (+) are not supported in SmallRAP.
  5921.  
  5922.    $blank            a single space
  5923.    #case             significance of case in character comparison
  5924.    $cmdline          holds user's command-line arguments
  5925.    $left             left-context of successful contains match
  5926.    $match            material matched in a successful contains
  5927.    $newline          a newline character (line feed)
  5928.    #paged            controls automatic pausing on full screen
  5929.    $path             directory path list used in accessing files
  5930.    $prompt           displayed by a or ah when asking for input
  5931.    #result           outcome of an xcall or xs command
  5932.    $right            right-context of successful contains match
  5933.    $screentype       Sharp LCD, IBM, or ANSI
  5934. +  #sstep            controls single-step tracing in /trace mode
  5935.                         (in LargeRAP only)
  5936.    $tag              response tag of most recent menu option
  5937.    $version          the version of RAP that is running
  5938.  
  5939.  
  5940.                          Loader commands
  5941.  
  5942. Items marked with a plus sign (+) are not supported in SmallRAP.
  5943.  
  5944. +  .define           define a symbolic constant name
  5945.    .include          insert another file into the input stream
  5946. +  .undef            abbreviation for .undefine
  5947. +  .undefine         remove a symbolic name definition
  5948.  
  5949.    .pragma           reserved for future use
  5950.    .ifdef            reserved for future use
  5951.    .else             reserved for future use
  5952.    .endif            reserved for future use
  5953.  
  5954.  
  5955.  
  5956. B. Formal syntax definition
  5957.  
  5958. [not included here, see printed book]
  5959.  
  5960.  
  5961.  
  5962. C. ANSI screen-control codes
  5963.  
  5964.                                 
  5965.                        Display attributes
  5966.  
  5967.     Code          Effect
  5968.     <esc>[0m      normal text
  5969.     <esc>[1m      high-intensity
  5970.     <esc>[4m      underlined (MDA display only)
  5971.     <esc>[5m      blinking
  5972.     <esc>[7m      reverse video
  5973.     <esc>[8m      concealed text
  5974.                   color display only:
  5975.     <esc>[3xm        set foreground color:
  5976.     <esc>[4xm        set background color. x can be:
  5977.     
  5978.                        0 - black  4 - blue
  5979.                        1 - red    5 - magenta
  5980.                        2 - green  6 - cyan
  5981.                        3 - yellow 7 - white
  5982.  
  5983.  
  5984.                                 
  5985.                          Cursor control
  5986.  
  5987.     Code          Effect
  5988.     <esc>[r;cH    move cursor to row r col c
  5989.                      (r and c are both numbers)
  5990.     <esc>[rA      move cursor up r rows
  5991.     <esc>[rB      move cursor down r rows
  5992.     <esc>[cC      move cursor right c columns
  5993.     <esc>[cD      move cursor left c columns
  5994.     <esc>[?7l     turn off line wrap
  5995.     <esc>[?7h     turn on line wrap
  5996.     <esc>[2J      clear screen and home cursor
  5997.     <esc>[K       clear to end of line
  5998.     <esc>[6n      report cursor position,
  5999.                      in form  <esc>[row,colR
  6000.     <esc>[s       save the cursor position
  6001.     <esc>[u       return cursor to saved position
  6002.  
  6003.  
  6004.  
  6005.              Video modes (IBM and compatibles only)
  6006.  
  6007.     Code          Effect -- selected mode
  6008.     <esc>[=0h     B&W 40x25 text
  6009.     <esc>[=1h     color 40x25 text
  6010.     <esc>[=2h     B&W 80x25 text
  6011.     <esc>[=3h     color 80x25 text
  6012.     <esc>[=4h     color 320x200 graphics
  6013.     <esc>[=5h     B&W 320x200 graphics
  6014.     <esc>[=6h     B&W 640x200 graphics
  6015.     <esc>[=8h     EGA 132x25 text (EGA only)
  6016.     <esc>[=9h     EGA 132x28 text (EGA only)
  6017.     <esc>[=10h    EGA 132x44 text (EGA only)
  6018.  
  6019.  
  6020.  
  6021. D. Input codes for special keys
  6022.  
  6023.   When a  special key  is pressed,  the first  character of input
  6024. received is  the null  character, so  that as  returns  an  empty
  6025. string the  first time  it is called.  This chart shows the ASCII
  6026. code corresponding to the second character of input.
  6027.  
  6028.                                 
  6029.                           Function keys
  6030.  
  6031.                  normal   with    with    with
  6032.             key   code   shift  control   alt
  6033.  
  6034.              F1    59      84      94     104
  6035.              F2    60      85      95     105
  6036.              F3    61      86      96     106
  6037.              F4    62      87      97     107
  6038.              F5    63      88      98     108
  6039.              F6    64      89      99     109
  6040.              F7    65      90     100     110
  6041.              F8    66      91     101     111
  6042.              F9    67      92     102     112
  6043.             F10    68      93     103     113
  6044.  
  6045.                                 
  6046.                            Cursor keys
  6047.  
  6048.                       normal       with
  6049.                   key  code      control
  6050.  
  6051.                 PrtSc              114
  6052.                  Home   71         119
  6053.              up-arrow   72          --
  6054.                  PgUp   73         132
  6055.                gray -   74          --
  6056.            left-arrow   75         115
  6057.           right-arrow   77         116
  6058.                gray +   78          --
  6059.                   End   79         117
  6060.            down-arrow   80          --
  6061.                  PgDn   81         118
  6062.              shft-tab   15
  6063.  
  6064.  
  6065.  
  6066.                          Other Alt keys
  6067.                                 
  6068.      Alt-1 120   Alt-Q 16   Alt-A 30   Alt-Z 44
  6069.      Alt-2 121   Alt-W 17   Alt-S 31   Alt-X 45
  6070.      Alt-3 122   Alt-E 18   Alt-D 32   Alt-C 46
  6071.      Alt-4 123   Alt-R 19   Alt-F 33   Alt-V 47
  6072.      Alt-5 124   Alt-T 20   Alt-G 34   Alt-B 48
  6073.      Alt-6 125   Alt-Y 21   Alt-H 35   Alt-N 49
  6074.      Alt-7 126   Alt-U 22   Alt-J 36   Alt-M 50
  6075.      Alt-8 127   Alt-I 23   Alt-K 37
  6076.      Alt-9 128   Alt-O 24   Alt-L 38
  6077.      Alt-0 129   Alt-P 25
  6078. Alt-hyphen 130
  6079.      Alt-= 131
  6080.  
  6081.  
  6082.  
  6083. E. Differences between RAP models
  6084.  
  6085.                              SmallRAP
  6086.  
  6087. 1. SmallRAP  only uses the memory it needs, leaving the rest free
  6088. for xs and xcall applications.
  6089.  
  6090. 2.  SmallRAP  does  not  support  these  commands  and  features:
  6091. ah, ce,  debug, dir,  edit, list,  pause, poke,  vnew,  vrestore,
  6092. vsave,  .define,   .undefine,  *currdir,   *currdriv,  *filesize,
  6093. *filetime, *fileymdt, *freesp, *isnumexp, *peek, and *volume.
  6094.  
  6095. 3. The only screens supported in SmallRAP are ANSI and Sharp LCD.
  6096. IBM's and clones need ANSI.SYS installed to use screen functions.
  6097.  
  6098. 4. SmallRAP  does not  check for  some less-common program errors
  6099. that normal RAP detects.
  6100.  
  6101. 5. SmallRAP  has a  fixed stack  size, and  may not handle deeply
  6102. nested subprogram calls as well as normal RAP.
  6103.  
  6104. 6. SmallRAP  is slightly slower than normal RAP.  SMALLRAP.EXE is
  6105. optimized more for size than speed.
  6106.  
  6107.                                 
  6108.                             LargeRAP
  6109.  
  6110. 1. LargeRAP  lets programs  and data  occupy  more  than  64K  of
  6111. memory.   This is  its reason for being:  to allow very large RAP
  6112. programs.
  6113.  
  6114. 2. LargeRAP  needs and  uses more  space to  store programs  than
  6115. normal or  SmallRAP.   Since LargeRAP  only uses  the  memory  it
  6116. needs, this  may still  turn  out  to  be  less  than  the  fixed
  6117. allocation of  normal RAP.  For large programs, LargeRAP will use
  6118. more memory than normal RAP.
  6119.  
  6120. 3. LargeRAP  is slower  than normal  or SmallRAP, because it must
  6121. use long pointers to access a program/data space which can exceed
  6122. 64K.  Typical performance is probably about 20% slower, depending
  6123. on program size and other considerations.
  6124.  
  6125. 4. LargeRAP  has a  fixed (though  large) stack size, and may not
  6126. handle deeply nested subprogram calls as well as normal RAP.
  6127.  
  6128. 5. LargeRAP  includes a  /trace feature for debugging programs.
  6129. This is described in section 10.3 .
  6130.  
  6131.